Comments comparing definitions.
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
(hissp.basic.._macro_.prelude)
|
(hissp.basic.._macro_.prelude)
|
||||||
|
|
||||||
|
;; Lissp's class definition syntax is somewhat unlike Python's class
|
||||||
|
;; definition syntax even though it expresses the same model. Python
|
||||||
|
;; will nearly never imply a dict from a sequence of uncoupled pairs
|
||||||
|
;; but this is a common way to express an association list in lisps.
|
||||||
|
;; It's interesting that `deftype` is a macro around a `type` call in
|
||||||
|
;; its rarely used form with three arguments. Quoting the
|
||||||
|
;; member/method (it does not distinguist) and class names for you in
|
||||||
|
;; the macro makes it read a little bit more like Python than it would
|
||||||
|
;; if you had to quote them.
|
||||||
(deftype Livesort ()
|
(deftype Livesort ()
|
||||||
__init__
|
__init__
|
||||||
(lambda (self
|
(lambda (self
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
(import [bisect [bisect]])
|
(import [bisect [bisect]])
|
||||||
|
|
||||||
|
;; Hy class definitions look a lot like Python class definitions.
|
||||||
|
;; Much moreso now. If one is not careful, it's easy to install an
|
||||||
|
;; older version of Hy and the class definition syntax has changed
|
||||||
|
;; over time. Hopefully this 1.0a syntax is now stable.
|
||||||
(defclass Livesort []
|
(defclass Livesort []
|
||||||
(defn __init__ [self
|
(defn __init__ [self
|
||||||
next-line ; iterable function yielding lines of text
|
next-line ; iterable function yielding lines of text
|
||||||
@@ -48,8 +52,7 @@ will update the display."
|
|||||||
(.sortline self line)
|
(.sortline self line)
|
||||||
(.print self (.display self)))))
|
(.print self (.display self)))))
|
||||||
|
|
||||||
(defmain
|
(defmain []
|
||||||
()
|
|
||||||
(import sys os)
|
(import sys os)
|
||||||
(.livesort
|
(.livesort
|
||||||
(Livesort sys.stdin
|
(Livesort sys.stdin
|
||||||
|
|||||||
Reference in New Issue
Block a user