Jump to page: 1 212  
Page
Thread overview
String literals
Jul 26, 2003
Walter
Jul 26, 2003
Russ Lewis
Jul 26, 2003
Walter
Jul 26, 2003
Sean L. Palmer
Jul 26, 2003
Walter
Jul 26, 2003
Ilya Minkov
Jul 28, 2003
Chris Lawson
Jul 27, 2003
Andy Friesen
Jul 26, 2003
Patrick Down
Jul 26, 2003
Walter
Jul 27, 2003
Fabian Giesen
Jul 27, 2003
Walter
Jul 26, 2003
Ilya Minkov
Jul 26, 2003
DeadCow
Jul 26, 2003
Walter
Jul 26, 2003
Walter
Jul 26, 2003
Luna Kid
Jul 26, 2003
Luna Kid
Jul 26, 2003
Walter
Jul 26, 2003
Luna Kid
Jul 26, 2003
John Reimer
Jul 26, 2003
Matthew Wilson
Jul 26, 2003
Ilya Minkov
Jul 27, 2003
John Reimer
Jul 27, 2003
Matthew Wilson
Jul 27, 2003
Walter
Jul 27, 2003
Sean L. Palmer
Jul 27, 2003
Ilya Minkov
Jul 27, 2003
John Reimer
Jul 27, 2003
Ilya Minkov
Jul 27, 2003
Walter
Jul 27, 2003
Ilya Minkov
Jul 26, 2003
Burton Radons
Jul 26, 2003
Walter
Jul 26, 2003
Burton Radons
Jul 27, 2003
Russ Lewis
Jul 28, 2003
Vathix
Jul 28, 2003
J. Daniel Smith
Jul 26, 2003
Matthew Wilson
Jul 26, 2003
Walter
Jul 27, 2003
Matthew Wilson
Jul 27, 2003
Walter
Jul 27, 2003
Matthew Wilson
Jul 27, 2003
Walter
Jul 28, 2003
Matthew Wilson
Jul 28, 2003
Walter
Jul 29, 2003
Mark T
Jul 27, 2003
Helmut Leitner
Jul 27, 2003
Walter
Jul 27, 2003
Vathix
Jul 27, 2003
sorry
Jul 27, 2003
Walter
Jul 27, 2003
Burton Radons
Jul 27, 2003
Walter
Jul 30, 2003
Burton Radons
Jul 27, 2003
Ilya Minkov
Jul 28, 2003
Matthew Wilson
Jul 27, 2003
Daniel Yokomiso
Jul 28, 2003
Sean L. Palmer
Jul 28, 2003
Charles Sanders
Jul 28, 2003
Andy Friesen
Jul 28, 2003
Sean L. Palmer
Jul 28, 2003
Mark Evans
Jul 28, 2003
Ilya Minkov
Jul 28, 2003
Bill Cox
Jul 28, 2003
Frank Wills
Jul 28, 2003
BenjiSmith
Jul 28, 2003
Karl Bochert
Jul 28, 2003
w
Jul 28, 2003
w
Jul 28, 2003
Mark Evans
Jul 28, 2003
Ilya Minkov
Jul 28, 2003
Walter
Jul 29, 2003
Sean L. Palmer
Jul 29, 2003
Walter
Jul 29, 2003
Dario
Jul 29, 2003
Mark Evans
Aug 07, 2003
j anderson
Aug 07, 2003
j anderson
Jul 28, 2003
Yeric
Jul 29, 2003
Walter
Cataclysmic decision re: String literals
Jul 29, 2003
Walter
Jul 29, 2003
Matthew Wilson
Jul 30, 2003
John Reimer
OT was Re: Cataclysmic decision re: String literals
Jul 30, 2003
Mark T
Jul 31, 2003
Walter
Aug 01, 2003
Mark T
Aug 01, 2003
Rich C
Jul 30, 2003
Ilya Minkov
Jul 30, 2003
Walter
Jul 30, 2003
Ilya Minkov
Jul 30, 2003
Mark Evans
Jul 30, 2003
Burton Radons
Jul 30, 2003
Burton Radons
Jul 30, 2003
Mark Evans
Jul 31, 2003
Sean L. Palmer
Jul 31, 2003
Mark Evans
Jul 31, 2003
Walter
Jul 31, 2003
Ilya Minkov
Jul 31, 2003
Matthew Wilson
Aug 01, 2003
Walter
Aug 01, 2003
Sean L. Palmer
Jul 30, 2003
Frank Wills
Jul 30, 2003
Walter
Jul 30, 2003
Burton Radons
Jul 30, 2003
Mark Evans
Jul 30, 2003
Mark Evans
Jul 31, 2003
Dario
Jul 31, 2003
Mark Evans
Jul 31, 2003
Walter
July 26, 2003
Currently, there are 3 kinds of string literals:
'string' : wysiwyg strings
"string" : escaped strings
\ : single character strings

There is no character literal syntax; 1 character long strings are implicitly converted to character literals based on context. Unfortunately, this leads to ambiguities with no reasonable way out (other than crafting arbitrary and confusing rules).

So, I've been thinking of going back to the C way and having ' ' for character literals. That means that wysiwyg strings are left without a lexical syntax. Any ideas for something that would look nice? How about using back quotes ` `, or is that just too hard to distinguish in certain fonts? One thing to keep in mind is that wysiwyg strings are not going to be used with nearly the same frequency as escaped strings, so the syntax can be a bit less convenient for them.

I'd like to use /string/, but that leads to too may lexical ambiguities.

Some possibilities are:
1) prefixing the " with a letter or a character, as in:
    W"string"
    %"string"
    !"string"
2) using a character not used in C, such as:
    `string`
    $string$
    @string@
    #string#


July 26, 2003
What about double double quotes for wysiwyg?

""string"" : wysiwyg string

I don't really like that syntax, but I think it's better than any of the other alternatives proposed so far.  I like the fact that it uses a quote character to denote a string, rather than some other, arbitrarily selected character.

Walter wrote:
> Currently, there are 3 kinds of string literals:
> 'string' : wysiwyg strings
> "string" : escaped strings
> \ : single character strings
> 
> There is no character literal syntax; 1 character long strings are
> implicitly converted to character literals based on context. Unfortunately,
> this leads to ambiguities with no reasonable way out (other than crafting
> arbitrary and confusing rules).
> 
> So, I've been thinking of going back to the C way and having ' ' for
> character literals. That means that wysiwyg strings are left without a
> lexical syntax. Any ideas for something that would look nice? How about
> using back quotes ` `, or is that just too hard to distinguish in certain
> fonts? One thing to keep in mind is that wysiwyg strings are not going to be
> used with nearly the same frequency as escaped strings, so the syntax can be
> a bit less convenient for them.
> 
> I'd like to use /string/, but that leads to too may lexical ambiguities.
> 
> Some possibilities are:
> 1) prefixing the " with a letter or a character, as in:
>     W"string"
>     %"string"
>     !"string"
> 2) using a character not used in C, such as:
>     `string`
>     $string$
>     @string@
>     #string#
> 
> 

July 26, 2003
"Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:bfuc2b$5ck$1@digitaldaemon.com...
> What about double double quotes for wysiwyg?
>
> ""string"" : wysiwyg string
>
> I don't really like that syntax, but I think it's better than any of the other alternatives proposed so far.  I like the fact that it uses a quote character to denote a string, rather than some other, arbitrarily selected character.

It's a good idea, but it conflicts with using "" to denote an empty string. I thought of using "'string'", but it looks too weird <g>.


July 26, 2003
"Walter" <walter@digitalmars.com> wrote in news:bfu9kp$3f1$1@digitaldaemon.com:

> Currently, there are 3 kinds of string literals:
> 'string' : wysiwyg strings
> "string" : escaped strings
> \ : single character strings
> 
> There is no character literal syntax; 1 character long strings are implicitly converted to character literals based on context. Unfortunately, this leads to ambiguities with no reasonable way out (other than crafting arbitrary and confusing rules).
> 
> So, I've been thinking of going back to the C way and having ' ' for character literals. That means that wysiwyg strings are left without a lexical syntax. Any ideas for something that would look nice? How about using back quotes ` `, or is that just too hard to distinguish in certain fonts? One thing to keep in mind is that wysiwyg strings are not going to be used with nearly the same frequency as escaped strings, so the syntax can be a bit less convenient for them.
> 
> I'd like to use /string/, but that leads to too may lexical ambiguities.
> 
> Some possibilities are:
> 1) prefixing the " with a letter or a character, as in:
>     W"string"
>     %"string"
>     !"string"

These are ok.

> 2) using a character not used in C, such as:
>     `string`
>     $string$
>     @string@
>     #string#

I think you should reserve these symbols for
other things.

Python uses """ for multi line strings.  I find it
useful.

a="""
Line 1
Line 2
"""



July 26, 2003
Walter wrote:
> Some possibilities are:
> 2) using a character not used in C, such as:
>     `string`
>     $string$
>     @string@
>     #string#

Using these ugly chacacters seems somewhat... ugly to me. Vote Against.

> 1) prefixing the " with a letter or a character, as in:
>     W"string"
>     %"string"
>     !"string"

Why do you want to prefix wysisyg strings? You may also prefix a string which is to mean character literal - which seems to make more sense to me.

W"" looks too much like wide-something.

Using % would prohibit overloading % as an operator where string is a second parameter. I consider ir useful as a formatting operator or somesuch.

! seems to be OK since it's a unary opertor anyway, and as such cannot be overloaded for a built-in types.

-i.

July 26, 2003
what about a perl-like quotation ?

s (for string?) followed by any character as delimiter.

s/.../
s#...#
s%...%
s!...!

So you can choose the delimiter to avoid escaping.

ok it's a bit ugly.
can the lexer handle this kind of backward reference ?

-- Nicolas Repiquet


July 26, 2003
I thought of that too, but it conflicts with '"' and "'".

What about '' (two single quotes)?

'c' // char
''string''  // wysiwyg string
"string"  // escaped string

I wouldn't be opposed to backquotes, either.

`string`

or

``string``

Unicode has some nice quotes too.

Sean

"Walter" <walter@digitalmars.com> wrote in message news:bfucor$64l$1@digitaldaemon.com...
>
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:bfuc2b$5ck$1@digitaldaemon.com...
> > What about double double quotes for wysiwyg?
> >
> > ""string"" : wysiwyg string
> >
> > I don't really like that syntax, but I think it's better than any of the other alternatives proposed so far.  I like the fact that it uses a quote character to denote a string, rather than some other, arbitrarily selected character.
>
> It's a good idea, but it conflicts with using "" to denote an empty
string.
> I thought of using "'string'", but it looks too weird <g>.


July 26, 2003
"More spectacularly" distinguishing char literals from string literals, in that they won't be surrounded by delimiters but just prefixed with something, may also be a good solution. (Char literals, after all, are totally different animals than string literals in many ways.) Then some prefix char and some simple rules to allow various (unambiguous) representations of a char need to be defined.

Sz.


"Walter" <walter@digitalmars.com> wrote in message news:bfu9kp$3f1$1@digitaldaemon.com...
> Currently, there are 3 kinds of string literals:
> 'string' : wysiwyg strings
> "string" : escaped strings
> \ : single character strings
>
> There is no character literal syntax; 1 character long strings are implicitly converted to character literals based on context. Unfortunately, this leads to ambiguities with no reasonable way out (other than crafting arbitrary and confusing rules).
>
> So, I've been thinking of going back to the C way and having ' ' for character literals. That means that wysiwyg strings are left without a lexical syntax. Any ideas for something that would look nice? How about using back quotes ` `, or is that just too hard to distinguish in certain fonts? One thing to keep in mind is that wysiwyg strings are not going to be used with nearly the same frequency as escaped strings, so the syntax can be a bit less convenient for them.
>
> I'd like to use /string/, but that leads to too may lexical ambiguities.
>
> Some possibilities are:
> 1) prefixing the " with a letter or a character, as in:
>     W"string"
>     %"string"
>     !"string"
> 2) using a character not used in C, such as:
>     `string`
>     $string$
>     @string@
>     #string#
>
>


July 26, 2003
> simple rules to allow various (unambiguous) representations
> of a char need to be defined.

Umm, those rules are already defined as EscapeSequence. :)

So, how about this?

Strings:

    'verbatim, as before'

    "escaped,\x20as\x20before"

Chars:

    #c    <-- letter 'c'
    ##    <-- is this problematic in D?
    #\t   <-- Tab
    #\x20 <-- Space
    #\\   <-- Backslash

Sz.


July 26, 2003
I like backquotes:

`string`

I don't think it's too confusing.

« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11