Re: Better string constants

Carl Gay <[email protected]>
Newsgroups gmane.comp.lang.dylan.gwydion.devel
Message-ID <CALekcH0Rd3m4_hBf7WVejyiyWsrU_MfpA_b8LySWofphTWOtHg@mail.gmail.com>
""" is like Python, which is rather popular, and ``` is similar to Go and
Markdown.  I guess #r""" would be closer to Python's r""" syntax than ```
is though.  I think that speaks in favor of #r""" over ```.

I'm not sure how to interpret your comment about interpolation.  I don't
see any reason to include anything like Ruby's "#{expression}" construct.
 I'd rather address that via a better replacement for "format".

On Wed, Feb 27, 2013 at 10:05 PM, Bruce Hoult <[email protected]> wrote:

> Unless there's a good reason to do otherwise, I'd suggest not being
> gratuitously different to popular languages, and in particular Ruby.
>
> http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals
>
> I'd love this to extend as far as interpolation (which would be
> auto-expanded to a series of concatenated string literals and
> as(<string>, ...) expressions). I'm not so sure about HERE documents.
>
> On Thu, Feb 28, 2013 at 3:55 PM, Carl Gay <[email protected]> wrote:
> > I really want better string constant syntax in Dylan.  Doing this sort of
> > thing...
> >
> >   parse-coil("A: {\n"
> >              "    a: 'a'\n"
> >              "    b: 'b'\n"
> >              "    c: 'c'\n"
> >              "}\n"
> >              ...
> > or
> >   "\"5\""
> >
> > is really tedious and error prone.  (Both of the above are from a test
> > suite.)
> >
> > We need two things:
> >   (1) raw string literals
> >   (2) multi-line strings
> >
> > Briefly, my suggestions are:
> > * Use """ for multiline backslash-interpreted strings.
> > * Use ` (backquote) for one-line raw strings.
> > * Use ``` for multi-line raw strings.
> >
> > `"5"` == "\"5\""
> > `\d+\.` == "\\d+\\."
> > ```A: {
> >   a: 'a'
> >   b: 'b'
> >   c: 'c'
> > }``` == the string near the top of this message.
> >
> > While I think it may be possible to use `...` for multi-line raw strings
> (as
> > Go does) it bothers me that there's no way to embed a backquote, and
> also I
> > like having the symmetry of "..." / """...""" and `...` / ```...```.
> >
> > Another possibility I like is #r"..." and #r"""...""" for raw strings.
> >
> > Thoughts/opinions?
>

_______________________________________________
hackers mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/hackers
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.