Re: Better string constants
Dustin Voss <[email protected]> Sat, 21 Feb 2015 16:29:29 -0800
| Newsgroups | gmane.comp.lang.dylan.gwydion.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1612844293== Content-type: multipart/alternative; boundary="Apple-Mail=_84ABA1DB-5E7A-4928-B998-DFBBA62122FE" --Apple-Mail=_84ABA1DB-5E7A-4928-B998-DFBBA62122FE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 The DEP says =E2=80=9Cprinting characters (including space)=E2=80=9D = which is analogous to what the DRM says for normal strings. I think you = also want to include the newline characters, otherwise you still = couldn=E2=80=99t actually hit =E2=80=9Creturn=E2=80=9D in a string. Right now the DEP excludes characters like line feed or tab or Unicode = control characters like bidi. I assume this is intentional. For the = purposes furthered by this DEP, it is probably better to use spaces = instead of tab characters. > On Feb 16, 2015, at 9:56 PM, Carl Gay <[email protected]> wrote: >=20 > As much as I wanted to wait a couple more weeks for the 2 year = anniversary of this thread, I decided to jump the gun. = http://opendylan.org/proposals/dep-0008.html = <http://opendylan.org/proposals/dep-0008.html> is a simple write-up of = multi-line string syntax. Comments on this thread. Thanks. >=20 >=20 > On Fri, Mar 1, 2013 at 12:30 AM, Carl Gay <[email protected] = <mailto:[email protected]>> wrote: > Just to summarize, I think it's fair to say that everyone so far is in = favor of (or at least is not against) """ to delimit multi-line = "interpreted" strings but there's not much support for raw string syntax = in the language. >=20 > I'll experiment with r-parser and possibly regex-parser, built on = that, and will (at some point in my copious free time) either implement = """ and/or write a DEP for it. >=20 >=20 > On Wed, Feb 27, 2013 at 9:55 PM, Carl Gay <[email protected] = <mailto:[email protected]>> wrote: > I really want better string constant syntax in Dylan. Doing this sort = of thing... >=20 > parse-coil("A: {\n" > " a: 'a'\n" > " b: 'b'\n" > " c: 'c'\n" > "}\n" > ... > or > "\"5\"" >=20 > is really tedious and error prone. (Both of the above are from a test = suite.) >=20 > We need two things: > (1) raw string literals > (2) multi-line strings >=20 > Briefly, my suggestions are: > * Use """ for multiline backslash-interpreted strings. > * Use ` (backquote) for one-line raw strings. > * Use ``` for multi-line raw strings. >=20 > `"5"` =3D=3D "\"5\"" > `\d+\.` =3D=3D "\\d+\\." > ```A: { > a: 'a' > b: 'b' > c: 'c' > }``` =3D=3D the string near the top of this message. >=20 > 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 = `...` / ```...```. >=20 > Another possibility I like is #r"..." and #r"""...""" for raw strings. >=20 > Thoughts/opinions? >=20 >=20 >=20 > _______________________________________________ > hackers mailing list > [email protected] > https://lists.opendylan.org/mailman/listinfo/hackers --Apple-Mail=_84ABA1DB-5E7A-4928-B998-DFBBA62122FE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = class=3D""><div class=3D"">The DEP says =E2=80=9Cprinting characters = (including space)=E2=80=9D which is analogous to what the DRM says for = normal strings. I think you also want to include the newline characters, = otherwise you still couldn=E2=80=99t actually hit =E2=80=9Creturn=E2=80=9D= in a string.</div><div class=3D""><br class=3D""></div><div = class=3D"">Right now the DEP excludes characters like line feed or tab = or Unicode control characters like bidi. I assume this is intentional. = For the purposes furthered by this DEP, it is probably better to use = spaces instead of tab characters.</div><div class=3D""><br = class=3D""></div><br class=3D""><div><blockquote type=3D"cite" = class=3D""><div class=3D"">On Feb 16, 2015, at 9:56 PM, Carl Gay <<a = href=3D"mailto:[email protected]" class=3D"">[email protected]</a>> = wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div = dir=3D"ltr" class=3D"">As much as I wanted to wait a couple more weeks = for the 2 year anniversary of this thread, I decided to jump the gun. = <a href=3D"http://opendylan.org/proposals/dep-0008.html" = class=3D"">http://opendylan.org/proposals/dep-0008.html</a> is a simple = write-up of multi-line string syntax. Comments on this = thread. Thanks.<div class=3D""><br class=3D""></div></div><div = class=3D"gmail_extra"><br class=3D""><div class=3D"gmail_quote">On Fri, = Mar 1, 2013 at 12:30 AM, Carl Gay <span dir=3D"ltr" class=3D""><<a = href=3D"mailto:[email protected]" target=3D"_blank" = class=3D"">[email protected]</a>></span> wrote:<br = class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 = .8ex;border-left:1px #ccc solid;padding-left:1ex">Just to summarize, I = think it's fair to say that everyone so far is in favor of (or at least = is not against) """ to delimit multi-line "interpreted" strings but = there's not much support for raw string syntax in the language.<div = class=3D""> <br class=3D""></div><div class=3D"">I'll experiment with r-parser and = possibly regex-parser, built on that, and will (at some point in my = copious free time) either implement """ and/or write a DEP for it.<div = class=3D""><div class=3D"h5"><br class=3D""><br class=3D""><div = class=3D"gmail_quote"> On Wed, Feb 27, 2013 at 9:55 PM, Carl Gay <span dir=3D"ltr" = class=3D""><<a href=3D"mailto:[email protected]" target=3D"_blank" = class=3D"">[email protected]</a>></span> wrote:<br = class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 = .8ex;border-left:1px #ccc solid;padding-left:1ex"> I really want better string constant syntax in Dylan. Doing this = sort of thing...<div class=3D""><br class=3D""></div><div class=3D""><div = class=3D""><font face=3D"courier new, monospace" class=3D""> = parse-coil("A: {\n"</font></div><div class=3D""><font face=3D"courier = new, monospace" class=3D""> = " a: 'a'\n"</font></div> <div class=3D""><font face=3D"courier new, monospace" class=3D""> = " b: = 'b'\n"</font></div><div class=3D""><font face=3D"courier new, monospace" = class=3D""> " = c: 'c'\n"</font></div><div class=3D""><font face=3D"courier new, = monospace" class=3D""> = "}\n"</font></div> </div><div class=3D""><font face=3D"courier new, monospace" = class=3D""> = ...</font></div><div class=3D""><font face=3D"courier new, = monospace" class=3D"">or</font></div><div class=3D""><font face=3D"courier= new, monospace" class=3D""> "\"5\""</font></div><div class=3D""> <br class=3D""> </div><div class=3D"">is really tedious and error prone. (Both of = the above are from a test suite.)</div><div class=3D""><br = class=3D""></div><div class=3D"">We need two things:</div><div = class=3D""> (1) raw string literals</div><div class=3D""> = (2) multi-line strings</div><div class=3D""><br class=3D""> </div> <div class=3D"">Briefly, my suggestions are:</div><div class=3D"">* Use = """ for multiline backslash-interpreted strings.</div><div class=3D"">* = Use ` (backquote) for one-line raw strings.</div><div class=3D"">* Use = ``` for multi-line raw strings.</div> <div class=3D""><br class=3D""></div><div class=3D"">`"5"` =3D=3D = "\"5\""</div><div class=3D"">`\d+\.` =3D=3D "<a href=3D"smb://d+//" = class=3D"">\\d+\\</a>."</div><div class=3D"">```A: {</div><div = class=3D""> a: 'a'</div><div class=3D""> b: 'b'</div><div = class=3D""> c: 'c'</div><div class=3D"">}``` =3D=3D the string = near the top of this message.</div> <div class=3D""><br class=3D""></div><div class=3D"">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 `...` / ```...```.</div> <div class=3D""><br class=3D""></div><div class=3D"">Another possibility = I like is #r"..." and #r"""...""" for raw strings.</div><div = class=3D""><br class=3D""></div><div = class=3D"">Thoughts/opinions?</div><div class=3D""><br class=3D""></div> </blockquote></div><br class=3D""></div></div></div> </blockquote></div><br class=3D""></div> _______________________________________________<br class=3D"">hackers = mailing list<br class=3D""><a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a><br = class=3D"">https://lists.opendylan.org/mailman/listinfo/hackers<br = class=3D""></div></blockquote></div><br class=3D""></body></html>= --Apple-Mail=_84ABA1DB-5E7A-4928-B998-DFBBA62122FE-- --===============1612844293== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ hackers mailing list [email protected] https://lists.opendylan.org/mailman/listinfo/hackers --===============1612844293==--