Skip to main content
added 7 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I think I'd like to learn Clojure eventually, but at the moment am having fun with Hy, a "dialect of lispLisp that's embedded in Python."

(import socket) (defn echo-upper (sock) (.send c (.upper (.recv c 10000))) (.close c) ) (def s socket.socket) (.bind s (tuple ["" 8000])) (.listen s 5) (while True (echo-upper (.__getitem__ (s.accept) 0)) ) 

Python generated from ABS with astor:

import socket def echo_upper(sock): c.send(c.recv(10000).upper()) return c.close() s = socket.socket s.bind(tuple([u'', 8000])) s.listen(5) while True: echo_upper(s.accept().__getitem__(0)) 

I'm not worried about not dealing with connections properly etc, I'd just like feedback on using lispy syntax. I'm tempted to do things like ((getattr s "bind") (tuple ["" 8000])) because it looks more like simple Scheme, the only lisp I have a little experience with. 

Any thoughts on syntax and style? GuidelinesAny guidelines for dealing with Python apisAPIs in a lispy way, something that apparently happens a lot in Clojure with Java?

I think I'd like to learn Clojure eventually, but at the moment am having fun with Hy, a "dialect of lisp that's embedded in Python."

(import socket) (defn echo-upper (sock) (.send c (.upper (.recv c 10000))) (.close c) ) (def s socket.socket) (.bind s (tuple ["" 8000])) (.listen s 5) (while True (echo-upper (.__getitem__ (s.accept) 0)) ) 

Python generated from ABS with astor:

import socket def echo_upper(sock): c.send(c.recv(10000).upper()) return c.close() s = socket.socket s.bind(tuple([u'', 8000])) s.listen(5) while True: echo_upper(s.accept().__getitem__(0)) 

I'm not worried about not dealing with connections properly etc, I'd just like feedback on using lispy syntax. I'm tempted to do things like ((getattr s "bind") (tuple ["" 8000])) because it looks more like simple Scheme, the only lisp I have a little experience with. Any thoughts on syntax and style? Guidelines for dealing with Python apis in lispy way, something that apparently happens a lot in Clojure with Java?

I think I'd like to learn Clojure eventually, but at the moment am having fun with Hy, a "dialect of Lisp that's embedded in Python."

(import socket) (defn echo-upper (sock) (.send c (.upper (.recv c 10000))) (.close c) ) (def s socket.socket) (.bind s (tuple ["" 8000])) (.listen s 5) (while True (echo-upper (.__getitem__ (s.accept) 0)) ) 

Python generated from ABS with astor:

import socket def echo_upper(sock): c.send(c.recv(10000).upper()) return c.close() s = socket.socket s.bind(tuple([u'', 8000])) s.listen(5) while True: echo_upper(s.accept().__getitem__(0)) 

I'm not worried about not dealing with connections properly etc, I'd just like feedback on using lispy syntax. I'm tempted to do things like ((getattr s "bind") (tuple ["" 8000])) because it looks more like simple Scheme, the only lisp I have a little experience with. 

Any thoughts on syntax and style? Any guidelines for dealing with Python APIs in a lispy way, something that apparently happens a lot in Clojure with Java?

added lisp tag; edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

Being Lispy Echoing back input in uppercase over a socket with Hy, a Python Lisp dialect

Tweeted twitter.com/#!/StackCodeReview/status/343731217402839040
Source Link
Thomas
  • 357
  • 1
  • 9
Loading