Wow, that's true! I don't use aand much so I didn't notice. Shorting on nil can definitely be a problem because sometimes you want to do something different; it's not very readable since "aand" suggests a boolean result; finally, my macro could be modified in different ways that diverge from the usual aand semantics (like having a special form to break from the pipeline).
well, we can closure the methods with the constructor function so they aren't duplicated, at the expense of explicitly requiring the object to be passed to them, or some kind of dispatch mechanism. we can also implement simple inheritance:
with (apply or ...) we could have a long inheritance chain, but here i have just two objects so the pattern is clear. we can then define objects like so:
(let _proto (obj
full (fn (self) (string self!first " " self!last))
until (fn (self year) (- year self!age)))
(def person (first last age)
(inherits (obj
_proto _proto
first first
last last
age age)
_proto))
)
arc> (= p (person "joe" "momma" 18))
#<procedure>
arc> (p!full p)
"joe momma"
arc> (p!until p 22)
4
arc> (= q (person "axe" "murderer" 10))
#<procedure>
arc> (q!full q)
"axe murderer"
arc> (q!until q 22)
12
because the inheritance is dynamically dispatched or whatitbe, we can alter the methods with the intended effects:
arc> (q!backwards q)
Error: "Function call on inappropriate object nil (#<procedure>)"
arc> (= ((q '_proto) 'backwards) (fn (self) (string self!last " " self!first)))
#<procedure:gs2439>
arc> (q!backwards q)
"murderer axe"
arc> (p!backwards p)
"momma joe"
arc> (= ((q '_proto) 'until) (fn (self age) "a long time"))
#<procedure:gs2451>
arc> (q!until q 22)
"a long time"
arc> (p!until p 18)
"a long time"
note the 'inherits' function is agnostic. we can inherit from arbitrary objects and functions or what have you, just that in this case it was used to inherit from a hidden prototype
anarki supposedly has user definable syntatic sugaries, so the (q!blah q) pattern could be sugarized
(def person (first last age)
(let self nil
(= self (obj
first first
last last
age age
full (fn () (string self!first " " self!last))
until (fn (year) (- year self!age))))))
Wow, that's much better! I didn't think that would work, since I thought that Arc's lexical scope bound variables in inner functions to the current value of those variables. Apparently I was wrong; thanks for the tip.
remember also that Arc autodestructurizes arguments based on the parameter list (example: http://arclanguage.org/item?id=6125.) scheme-style def would would conceptually interfere with that
though maybe scheme autodestructurizes like that also? i don't know
so that args is the list of all arguments, and rest is the list of all arguments after the first two. I suppose the equivalent scheme-ish way would be
(def (foo . args) ...
(def (foo x y . args) ...
I like the fact that arc has no special &rest keyword, that rest args just fall out of the way lists are constructed.
I haven't used scheme so I'm not qualified to comment (but obviously that's not stopping me), but to this n00b it makes sense that the parameter list is distinct from the function name. And as you mention it makes named functions look more similar to anonymous functions. So I have less thinking to do when I'm looking at a parameter list.
Lisp is not popular because it was not at the right place at the right time. Other languages were, but that is all they were. Lisp meanshile is as good (and superior) as it ever was. And it is catching on, part of why I ranted that it is time to stop wringing our hands over Lisp's popularity and start programming with it. Or Arc. :)
The system uses some sort of equation based on the submission time and points of each topic to determine the topic ordering. Changing that equation to use the last response time of each topic would do it.
The original pg article referenced was about having local variables without a let. This article, as a whole, is a bit confused, so it's hard to know what he's trying to say. Bottom line, I don't think he got the gist of the pg essay he references...