5 ms·
>(<function or macro name> arg1 arg2 ...) >That's it. This is 100% of the syntax. (list '(1 . (#x-A 2.3 |(+ foo bar)| #|4|# #\#)) (1+ '#C(-5/6
by GregBuchholz 9y ago
>(<function or macro name> arg1 arg2 ...)
>That's it. This is 100% of the syntax.
(list '(1 . (#x-A 2.3 |(+ foo bar)| #|4|# #\#))
(1+ '#C(-5/6 +7.s-8))
"(* 9 10)" () #()) ; and then some
- Johnny_Brahms 9y agoWhich fits the grammar. Sure, you are using some literals, but that is an application of the list procedure with 5 arguments.
- Johnny_Brahms 9y agoHaha. I just proved you right. Common lisp apparently has block comments.
- TeMPOraL 9y agoOf course it does. #| this is commented out |#. Comment syntax is usually something "special" in each language anyway.
- Johnny_Brahms 9y agoAnd I didn't know it, hence me thinking there were 5 arguments.
- GregBuchholz 9y agoThat's all one expression, and there are 5 argument to the list procedure: 1.) a list containing three numbers, a symbol, and a character, 2.) a complex number, 3.) a string, 4.) the symbol "NIL", 5.) the empty vector.
- Johnny_Brahms 9y agoI shouldnt have read it a second time on my phone. I was right the first time. :)
- lispm 9y agoYou can use them as block comments. But they are actually just reader macros which return nothing. They skip over the enclosed content.
- mschaef 9y ago> that is an application of the list procedure That really depends on the current package at the time the form is read, and then how `list` is defined within that package. Strictly speaking, you don't even know which 'list' symbol is referenced without that context. (And in that context, list could be bound to a macro, or it could be unbound entirely.)
- didibus 9y agoOh wow lol. Well maybe Common Lisp complicated the syntax further. I only know scheme and Clojure. Though much of the time, lisp implementations adds syntax as shortend, and you can also do all that with the syntax I described.
- GregBuchholz 9y agoWell, Scheme has a bunch of syntax as well. (list '(1. . #\#) -5/6+7.s-8i `(1 ,@2) 1@1 ;hmmm, no unquote splicing comma ;-) 10# ;surprised? (list #i+1 +1i 1+i) ;complicated or complex? #e-1e10i ;Old MacDonald? "(* 9 10)" #()) ...how many can you guess without running the example? (I checked it with Dr. Racket under R5RS mode)
- soegaard 9y agoApropos: The meaning of # in Scheme number syntax: https://stackoverflow.com/q/10935110/23567 https://stackoverflow.com/q/10935110/23567
- didibus 9y agoHum, I confess, there's some weird ones. 1) A list of 1.0 and the pound char. 2) I'm guessing a complex number. 3) A list of 1 and an explicitly evaluated 2. 4) Hum, would it just be a symbol? 5) I am surprised. Maybe just another symbol? 6) More complex numbers. 7) Another complex number? 8) A string 9) An empty vector. Without the complex numbers, which I admit I've never used, it's not that bad. They're just shortend, you can use list, vector, quote, unquote, unquote-splicing and quasiquote functions instead. I think there's a function for char too, name->char I think. The ones that are weird are 1@1 and 10#. Anyways, there's a bit more syntax it's true, but all of that is literals. I'm not sure that counts as syntax, I guess it does. So ya, there's a little more than I said. Maybe it's easier to say I can explain the semantics in one minute and the syntax in two minutes?