Earlier quoted context omitted.
Homoiconicity.
C has homoiconicity: you can represent C source code as C strings.
A Friendly Introduction to Racket
81–90 of 195 posts
Re: A Friendly Introduction to Racket
#82> no special syntax for anything. (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)" #())
You forgot hash table and regular expression literals.
'#0=(0 . #0#)
...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2)))
(display |1 + 2|))Re: A Friendly Introduction to Racket
#83I first met Common Lisp during my college years in early 2000s: we had an enthusiast teacher who taught it for free, in his free time; it was interesting for me as a freshman to learn something new, but also I literally had no idea how to write Lisp code properly, without resorting to using `progn` here and there. For those not aware, `progn` is a form that allows you to write expressions in a sequential way, pretty much like you use the C compound statement, a `{ ... }` block. It works, and after some time you find that you're writing in some crappy imperative programming language with a lot of brackets but you don't learn much about the functional programming.
It took me more than a year, and definitely more than any short “friendly introduction”, to understand the functional approach.
Now, Racket. I first noticed it while doing my daily LeetCode; they added Racket as a supported language and you can go use it to solve a task. After not using Lisp for 20-something years, I appreciated the opportunity, but I found the type contract syntax infuriating. This is LeetCode #1, “Two sum”:
(define/contract (two-sum nums target)
(-> (listof exact-integer?) exact-integer? (listof exact-integer?))
)
I don't know what you feel, but this makes me want to close this tab and never return. So if I find myself wanting to write some Lisp and there's a daily LeetCode task I want to solve, the first thing I do is I delete all this garbage and come back to the clean option: (define (two-sum nums target) ...)
which, except for the minor syntax differences, brings me back to my college Lisp years and I can actually enjoy it.Re: A Friendly Introduction to Racket
#84Re: A Friendly Introduction to Racket
#85Earlier quoted context omitted.
You forgot hash table and regular expression literals.
It looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))
Re: A Friendly Introduction to Racket
#86Re: A Friendly Introduction to Racket
#87Earlier quoted context omitted.
C has homoiconicity: you can represent C source code as C strings.
You can show this is possible, but it is extremely onerous in comparison.
Re: A Friendly Introduction to Racket
#88Earlier quoted context omitted.
It looks like Racket nerfed the shared-structure / "Datum Labels" for circular lists and the like (I see it is still in section 2.4 of r7rs): '#0=(0 . #0#) ...and I should have included `#|block comments|#`, datum `#;comments`, and probably `|symbols with spaces|`. (let ((|1 + 2| (+ 1 2))) (display |1 + 2|))
That has been in Racket for a long time.
#lang racket/base
(let ((a '#0=(0 . #0#)))
(display (car a)))
...over athttps://onecompiler.com/racket
...and it didn't compile, complaining:
read-syntax: `#...=` forms not enabled for `read-syntax` mode
...maybe there is a switch needed to enable it?Re: A Friendly Introduction to Racket
#89While the language is interesting, sadly, nobody is using it in the wild. Maybe due to cumbersome deployment options? The ability to produce native standalone executables would boost its usage I believe.
Re: A Friendly Introduction to Racket
#90Earlier quoted context omitted.
That has been in Racket for a long time.
I tried: #lang racket/base (let ((a '#0=(0 . #0#))) (display (car a))) ...over at https://onecompiler.com/racket ...and it didn't compile, complaining: read-syntax: `#...=` forms not enabled for `read-syntax` mode ...maybe there is a switch needed to enable it?
#lang racket
(let ((a (read (open-input-string "#0=(0 . #0#)"))))
(display (car a)))
I think the problem is that `read` / `write` support shared data constructed using `shared`. But programs (read by `read-syntax` are not allow to have cycles.