Fwd: [racket] Adding raw string syntax

10 views
Skip to first unread message

Rodolfo Carvalho

unread,
Aug 10, 2011, 5:44:55 PM8/10/11
to rack...@googlegroups.com
Voces viram essa thread?

Muito bacana o exemplo que o Joan dá no blog dele.

[]'s

Rodolfo Carvalho


Forwarded conversation
Subject: [racket] Adding raw string syntax
------------------------

From: Joan Arnaldich <jarna...@gmail.com>
Date: Sun, Aug 7, 2011 at 12:44
To: us...@racket-lang.org


Hi there!

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

----------
From: Sam Tobin-Hochstadt <sa...@ccs.neu.edu>
Date: Tue, Aug 9, 2011 at 13:20
To: Joan Arnaldich <jarna...@gmail.com>
Cc: us...@racket-lang.org


On Sun, Aug 7, 2011 at 10:44 AM, Joan Arnaldich <jarna...@gmail.com> wrote:

> [snip]

I love your post -- it's great to have lots of people writing about
their experience hacking in Racket.
The @ syntax originally designed for Scribble is very helpful for this
sort of thing.
--
sam th
sa...@ccs.neu.edu

----------
From: Eli Barzilay <e...@barzilay.org>
Date: Tue, Aug 9, 2011 at 13:27
To: Sam Tobin-Hochstadt <sa...@ccs.neu.edu>
Cc: us...@racket-lang.org, Joan Arnaldich <jarna...@gmail.com>


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!

----------
From: Jos Koot <jos....@telefonica.net>
Date: Tue, Aug 9, 2011 at 14:19
To: Joan Arnaldich <jarna...@gmail.com>, us...@racket-lang.org


Thanks for sharing your tutorial (it is, although your initial intention was
as a reminder for yourself) Very clear exposition. You made a very important
step by discovering how to make your own languages. In the long past I have
made many languages for specific applications, but without the nice tools of
Racket (fortran and an assembler with a very good macro system allowing
recursion and meta macros, id est macros that produce macros) Making a
language with these tools would require a 1000 to 10000 lines of code. With
Racket a hundred or a few hundred lines of code may be sufficient. I share
your enthousiasm for Racket.
Kind regards, Jos

-----Original Message-----
From: users-...@racket-lang.org [mailto:users-...@racket-lang.org]
On Behalf Of Joan Arnaldich
Sent: domingo, 07 de agosto de 2011 17:44
To: us...@racket-lang.org
Subject: [racket] Adding raw string syntax

----------
From: Joan Arnaldich <jarna...@gmail.com>
Date: Wed, Aug 10, 2011 at 04:34
To: us...@racket-lang.org


Aha! So there it was! Thanks a lot for the pointer! Ignorance is
always ignorance, but... I can't help thinking that if I had known
that I would have missed a lot of fun ;)

----------
From: Jukka Tuominen <jukka.t...@finndesign.fi>
Date: Wed, Aug 10, 2011 at 05:39
To: Joan Arnaldich <jarna...@gmail.com>, us...@racket-lang.org



Not much of an analogy, but I've always found the following thought
inspiring:

"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
> Sent: 10 August 2011 10:35
> Subject: Re: [racket] Adding raw string syntax

----------
From: Joan Arnaldich <jarna...@gmail.com>
Date: Wed, Aug 10, 2011 at 16:08
To: us...@racket-lang.org


Not even using lexer/parser generators... hats
up! (and shrivers down my spine...) ;)
Thanks for the answer, Jos!

----------
From: Joan Arnaldich <jarna...@gmail.com>
Date: Wed, Aug 10, 2011 at 18:37
To: us...@racket-lang.org


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!


Reply all
Reply to author
Forward
0 new messages