5 ms·
Lambda’s New Coat: 21st century syntactic Mexps
- rbarooah 16y agoDeclaring that lisp is unintuitive when compared with python is like saying Shakespeare is unpopular when compared with Lady Gaga.
- noss 16y agoOkay, how was it, did Lisp introduce if expressions or if statements?
- lubutu 16y agolisp introduced if-then-else expressions. 'if statements' was a little vague, so i've rephrased. i wasn't really expecting to be on hn :/
- evangineer 16y agoThe article made an interesting proposal. Do you intend to implement it?
- lubutu 16y agoi'd like to, it's just a case of finding the time. i'm sure i'll get around to it at some point.
- spacemanaki 16y agoThis proposal is very similar to "sweet expressions": http://www.dwheeler.com/readable/sweet-expressions.html http://www.dwheeler.com/readable/sweet-expressions.html edited to add: "it makes the language far more flexible than any other language and provides a foundation for fully hygienic macros: you can modify the program entirely while it’s running and guarantee that there will be no crazy conflict behaviour. " That's not true though, Common Lisp's macros can have nasty variable capture issues, can't they? This isn't using the word "hygienic" in the sense of Scheme's, so what does this mean exactly?
- lubutu 16y agothanks, i'd not read this. they do seem quite similar, though i think we focus on different things. i think i prefer haskell operators to infixing with {}. still, i hadn't considered subscripting.
- oconnore 16y agoCommon Lisp macros allow the programmer to capture variables if they desire and/or are ignorant of the semantics of the language. Sometimes this is nice, like in the anaphora package. Defining hygienic macros is not hard though.
- spacemanaki 16y agoThat's basically what I thought. I misread the OP to mean that s-expressions alone guaranteed hygienic macros.
- jpr 16y agoShouldn't this if fruit is 'apricot': be if fruit == 'apricot': ?
- lubutu 16y agoin python they're equivalent (for strings and numbers and such).
- devinj 16y agoNope; that's a common misconception. >>> "1"*1000 is "1"*1000 False >>> 2**31 is 2**31 False The fact is that the only thing guaranteed by "is" is that if you have "a = b", then "a is b". Whether or not "new" objects are going to be identical to old ones is left undefined, and may change depending on type or value.
- jacobolus 16y agoSure. `==` should be used for such comparisons, not `is`, as the latter is semantically different. They have the same effect for "apricot" because Python interns strings up to length 20: >>> "1"*20 is "1"*20 True >>> "1"*21 is "1"*21 False
- lubutu 16y agothat is very confusing, but fair enough. it at least seems to work in the sample code.
- lubutu 16y agofine fine, i've changed the code slightly. sometimes i wonder whether i am too imprecise for a programmer. :o
- devinj 16y agoWell, "is" in Python is a specific notion of object identity, and Python happens to sometimes decide it's not worth creating new objects. Not really confusing, it's just completely different from '==' (except by coincidence basically).
- ynniv 16y agoThis idea comes up periodically, but it's something that appeals more to those who don't use lisp than those who do. I thought the same thing before I started really using lisp, but once you start feeling comfortable with sexps a superficial pythonic skin sounds annoying. The suggestion of trading lisp's macro features (how would you define macros with "mexps", and how would mexps interact with macros?) for syntactic whitespace that people either love or hate doesn't sound like a long term improvement. "Mexps" might attract a few new people to lisp, but the existing lisp community would reject them. It would be more effective in the long term to show people the value of lisp's existing syntax.
- lubutu 16y agomaybe an alternative to sexps appeals to those who don't use lisp because they don't use lisp because of sexps? the idea is that mexps translate directly (and simply) into sexps, so macros would work in exactly the same way as they do now.
- ataggart 16y ago>However, Lisp has a big problem: it’s not intuitive. Something about nipples comes to mind.
- Apocryphon 16y agoA Python with a Lisp- Parseltongue?
- deleted 16y ago[deleted]