Re:Literals in Programming Languages
by jmmcd on Thursday February 28, 2013 @06:03AM
(#5298115)
This article is only about primitive literals, not compound ones. I think the list and dict literals in Python are the #1 reason I like it better than C. I think the regexp literals in Perl were one of the main reasons people liked Perl better than C.
[ Parent
| on HN ]
That line blurs when you have homoiconic syntax, specially one with a programmable reader. Common Lisp uses the # for dispatch macro character, you can define your own literals, in whatever environment you want.
http://www.franz.com/support/documentation/6.2/ansicl/subsec...
Can't you set any dispatch character you like using make-dispatch-macro-character ?
Oh yes, you can set your own dispatch characters, but the # is the dispatch character for the CL standard syntax.
C99 has array and struct literals:
(int []) { 1, 2, 3 }
(struct Point) { 3, 5 }
(struct Point) { .x = 3, .y = 5 }> This article is only about primitive literals, not compound ones.
It mentions array literals: http://www.gavilan.edu/csis/languages/literals.html#_Toc7587...
Re:Literals in Programming Languages
by pilgrim689 on Thursday February 28, 2013 @08:57AM
(#5298624)
> I like [Python] better than C
Isn't it strange to compare Python/Perl to C and say that one is better than the other? It's apples to oranges. You wouldn't use Python or Perl to build an OS, and you wouldn't use C to prototype a web app.
Sure, but I said "like", not "better". When I learned Python, I had that feeling described as weightlessness by xkcd [http://xkcd.com/353/], because I didn't have to write several lines and a loop to make a list. It made me happy. Fair comparisons don't really come into it.