I'm just starting to learn Racket. One of the thing that I appreciate
most so far is the language extensibility (IMHO, the feature that
makes it so unique compared to other languages...). So, when I
couldn't find anything like python's raw string syntax (strings
introduced by r'') or c#'s @"" strings, I thought... well, let's try a
bit of language DIY...
So I went through the Guide and the brainfudge tutorial and came up
with a solution that worked as I wanted. I blogged about it here:
http://jarnaldich.me/2011/08/07/raw-strings-in-racket.html
In fact, I wrote that entry (well most of them...) more as a reminder
for myself than as a tutorial, but I still think it makes sense to
publish it, if only to demonstrate how you can tune the language to
match your personal tastes... something you can't do in every
language, for sure...
The problem is, as I said, that I'm just starting with Racket, so
while the solution works as expected so far, maybe I misunderstood or
skipped something in the documentation and just got it all wrong... so
any comments would be much appreciated, if only to reassure myself...
BTW, I searched the list and the docs for this feature before
implemeting mine... the only thing I found were some old questions on
backslashing in strings for regexes. But maybe this was already
implemented somewhere else and I couldn't find it...
Thanks in advance!
Joan.
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/users
> [snip]
I love your post -- it's great to have lots of people writing about
their experience hacking in Racket.
> BTW, I searched the list and the docs for this feature before
> implemeting mine... the only thing I found were some old questions on
> backslashing in strings for regexes. But maybe this was already
> implemented somewhere else and I couldn't find it...
The @ syntax originally designed for Scribble is very helpful for this
sort of thing.
--
sam th
sa...@ccs.neu.edu
A concrete example for using it as a raw string:
#lang at-exp racket
(define r string-append)
(display @r{...nearly free text here...})
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
"People that are busy trying to convince something cannot be done, mustn't
disturb the ones that are already doing it!"
(Sorry, could't find who's quote it is).
Racket seems to be the tool for the doers - the threashold to DIY is very
low, as we have seen many times.
br, jukka
> -----Original Message-----
> From: users-...@racket-lang.org
> [mailto:users-...@racket-lang.org]On Behalf Of Joan Arnaldich
Not even using lexer/parser generators... hats
up! (and shrivers down my spine...) ;)
Thanks for the answer, Jos!
> Racket seems to be the tool for the doers - the threashold to DIY is very
> low, as we have seen many times.
I see what you mean. Racket makes it hard to find those kind of
excuses: if you don't like or miss something, you can always go and
change it. How many languages will let you do that?
Thanks for the quote, Jukka!
Yes, it's certainly a good exercise in trying to get a quick
readtable-based grammar extension.
And speaking about this, I've noticed that someone put a link to your
tutorial on the Wikipedia page -- and I worry about getting more
people who are unaware of the scribble @-form syntax that does things
better when more people see it. Do you mind editing your post and
adding the above note so people won't miss it?
(I prefer that over dropping the reference, because it *is* a good
exercise in a quick extension, I just want to avoid people spending
time getting something like this more polished when the work is
already there.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
> I've noticed that someone put a link to your
> tutorial on the Wikipedia page --
It was Asumu. I wouldn't feel confident enough for such a
self-plug ;P.
> and I worry about getting more
> people who are unaware of the scribble @-form syntax that does things
> better when more people see it. Do you mind editing your post and
> adding the above note so people won't miss it?
Done. I added a section at the end on the @form syntax, and a
note at the beggining so that people can skip the whole article if
they just want to get the functionality.
> (I prefer that over dropping the reference, because it *is* a good
> exercise in a quick extension, I just want to avoid people spending
> time getting something like this more polished when the work is
> already there.)
If the tutorials section in the article section is to stay, then I'll
add this one here, which I think is far more interesting than
mine:
http://matt.might.net/articles/implementing-a-programming-language/
Speaking of the article, after Asumu's mail I started to contribute a
little bit. I was planning to focus on the practical side of Racket,
so I added a brief section on this. I would like to add a link at the end of
the section pointing at a new wikipedia page with examples on how
Racket can be used in different application domains, and to show some
of the different languages / paradigms available (a bit like the
Haskell page does in the features section)... the problem is that it
is hard to come up with better examples than the ones already at
racket-lang.org, so could I use some of those (always with the
reference)?. I think more wikipedia readers will get to see the
examples if they're in a regular wikipedia page rather than having to
click to an external link and then browse back and forth and click on
the question mark for an explanation.
> If the tutorials section in the article section is to stay, then I'll
> add this one here, which I think is far more interesting than
> mine:
>
> http://matt.might.net/articles/implementing-a-programming-language/
But Matt's page is just a discussion of interpreters.
That's a rather different notion of implementing a
language. You could do so in asm, no real tools needed.
>
> Speaking of the article, after Asumu's mail I started to contribute a
> little bit. I was planning to focus on the practical side of Racket,
> so I added a brief section on this. I would like to add a link at the end of
> the section pointing at a new wikipedia page with examples on how
> Racket can be used in different application domains, and to show some
> of the different languages / paradigms available (a bit like the
> Haskell page does in the features section)... the problem is that it
> is hard to come up with better examples than the ones already at
> racket-lang.org, so could I use some of those (always with the
> reference)?. I think more wikipedia readers will get to see the
> examples if they're in a regular wikipedia page rather than having to
> click to an external link and then browse back and forth and click on
> the question mark for an explanation.
A very good idea. When I made screen savers for my Mac from
them, I placed them on the web here (by accident):
http://www.ccs.neu.edu/home/matthias/Presentations/10ICFP/Background/
Thanks!
> If the tutorials section in the article section is to stay, then
> I'll add this one here, which I think is far more interesting than
> mine:
>
> http://matt.might.net/articles/implementing-a-programming-language/
Matthias Felleisen wrote:
>
> But Matt's page is just a discussion of interpreters.
> That's a rather different notion of implementing a
> language. You could do so in asm, no real tools needed.
Yeah -- when building an interpreter Racket does have its advantages,
but at that level it's pretty close to many other functional
languages. In any case, it looks like someone else saw that and
removed the entry.
> Speaking of the article, after Asumu's mail I started to contribute
> a little bit. I was planning to focus on the practical side of
> Racket, so I added a brief section on this. I would like to add a
> link at the end of the section pointing at a new wikipedia page with
> examples on how Racket can be used in different application domains,
> and to show some of the different languages / paradigms available (a
> bit like the Haskell page does in the features section)... the
> problem is that it is hard to come up with better examples than the
> ones already at racket-lang.org, so could I use some of those
> (always with the reference)?. I think more wikipedia readers will
> get to see the examples if they're in a regular wikipedia page
> rather than having to click to an external link and then browse back
> and forth and click on the question mark for an explanation.
That sounds like a very good idea -- not only include them, but also
add some descriptions. To get all the example sources in a convenient
way, you can just look in the source file that has them:
http://git.racket-lang.org/plt/blob/HEAD:/collects/meta/web/www/index.rkt
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
Something I think we've all seen with technology marketing (yeah, I
said the m-word): When I've built something, there's a natural
tendency to focus on what's-new-in-this-version or
what-makes-us-better-than-the-competition. That's what's most
interesting to me, to gatekeepers, and even to some subset of
customers. But many potential customers are interested in the basic
story, including all the bits that are old and unremarkable to me.
Plus in the case of Racket it might help to have more mundane
examples, rather than fewer. Such examples help convey: "See, you can
do practical stuff in Racket just like in your blub language. There's
all this other power and expressiveness waiting for you to try, when
you're ready. But Racket isn't only for PL researchers. Oh and don't
worry, you won't need Leibniz to printf."
> Plus in the case of Racket it might help to have more mundane
> examples, rather than fewer. Such examples help convey: "See, you can
> do practical stuff in Racket just like in your blub language. There's
> all this other power and expressiveness waiting for you to try, when
> you're ready. But Racket isn't only for PL researchers. Oh and don't
> worry, you won't need Leibniz to printf."
Agreed. In fact, I just added a wikipedia page with Racket code
examples. Most of them come from Racket's main page, but I think it
would be nice to add some practical and short applications of the kind
"look what you can do in only 7 lines of Racket"... that's why I added
the grep-like example... if you think that's ok, feel free to add your
own...
The page is here:
http://en.wikipedia.org/wiki/Racket_features#Language_extensions
I'll post more details on my modifications to the wikipedia article thread.