Re: Better string constants
Carl Gay <[email protected]> Tue, 17 Feb 2015 00:56:02 -0500
| Newsgroups | gmane.comp.lang.dylan.gwydion.devel |
|---|---|
| Message-ID | <CALekcH2UPih95c3AcAgb3nM1ZtXJCwB59k3kSCGOXNb4ppm7Yw@mail.gmail.com> |
--===============0773694870== Content-Type: multipart/alternative; boundary=001a1134b96491ef71050f425bff --001a1134b96491ef71050f425bff Content-Type: text/plain; charset=UTF-8 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 is a simple write-up of multi-line string syntax. Comments on this thread. Thanks. On Fri, Mar 1, 2013 at 12:30 AM, Carl Gay <[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. > > 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. > > > On Wed, Feb 27, 2013 at 9: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? >> >> > --001a1134b96491ef71050f425bff Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">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. =C2=A0<a href= =3D"http://opendylan.org/proposals/dep-0008.html">http://opendylan.org/prop= osals/dep-0008.html</a> is a simple write-up of multi-line string syntax.= =C2=A0 Comments on this thread.=C2=A0 Thanks.<div><br></div></div><div clas= s=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, Mar 1, 2013 at 12:= 30 AM, Carl Gay <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a>></span> wrote:<br><blockquote cl= ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p= adding-left:1ex">Just to summarize, I think it's fair to say that every= one so far is in favor of (or at least is not against) """ t= o delimit multi-line "interpreted" strings but there's not mu= ch support for raw string syntax in the language.<div> <br></div><div>I'll experiment with r-parser and possibly regex-parser,= built on that, and will (at some point in my copious free time) either imp= lement """ and/or write a DEP for it.<div><div class=3D"h5">= <br><br><div class=3D"gmail_quote"> On Wed, Feb 27, 2013 at 9:55 PM, Carl Gay <span dir=3D"ltr"><<a href=3D"= mailto:[email protected]" target=3D"_blank">[email protected]</a>></span= > wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo= rder-left:1px #ccc solid;padding-left:1ex"> I really want better string constant syntax in Dylan.=C2=A0 Doing this sort= of thing...<div><br></div><div><div><font face=3D"courier new, monospace">= =C2=A0 parse-coil("A: {\n"</font></div><div><font face=3D"courier= new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0" =C2= =A0 =C2=A0a: 'a'\n"</font></div> <div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0" =C2=A0 =C2=A0b: 'b'\n"</font></div><di= v><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0" =C2=A0 =C2=A0c: 'c'\n"</font></div><div><f= ont face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0"}\n"</font></div> </div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0...</font></div><div><font face=3D"courier new, mon= ospace">or</font></div><div><font face=3D"courier new, monospace">=C2=A0 &q= uot;\"5\""</font></div><div> <br> </div><div>is really tedious and error prone. =C2=A0(Both of the above are = from a test suite.)</div><div><br></div><div>We need two things:</div><div>= =C2=A0 (1) raw string literals</div><div>=C2=A0 (2) multi-line strings</div= ><div><br> </div> <div>Briefly, my suggestions are:</div><div>* Use """ for mu= ltiline backslash-interpreted strings.</div><div>* Use ` (backquote) for on= e-line raw strings.</div><div>* Use ``` for multi-line raw strings.</div> <div><br></div><div>`"5"` =3D=3D "\"5\""</div= ><div>`\d+\.` =3D=3D "\\d+\\."</div><div>```A: {</div><div>=C2=A0= a: 'a'</div><div>=C2=A0 b: 'b'</div><div>=C2=A0 c: 'c&= #39;</div><div>}``` =3D=3D the string near the top of this message.</div> <div><br></div><div>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 emb= ed a backquote, and also I like having the symmetry of "..." / &q= uot;""...""" and `...` / ```...```.</div> <div><br></div><div>Another possibility I like is #r"..." and #r&= quot;""...""" for raw strings.</div><div><br></div= ><div>Thoughts/opinions?</div><div><br></div> </blockquote></div><br></div></div></div> </blockquote></div><br></div> --001a1134b96491ef71050f425bff-- --===============0773694870== 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 --===============0773694870==--