> I think string literals should contain exactly what they contain in their
source form, without any additional processing. If you want to express
characters that are inconvenient to type, you can use control sequences and
a (standard) formatting library to produce them.

I'm actually very intrigued by the idea of eliminating escape characters
altogether in the default string literals. Would follow nicely from how we
allow newlines in string literals. We'd have to give up the optional
"whitespace-chomping" behavior around newlines, though, which would make me
pretty sad. And are you really willing to force everyone who wants to
include a quotation mark in a string to go through a syntax extension to do
it?

<facetious>

People, please! Using delimiters on string literals is tantamount to
checking for null to determine when you've reached the end of a string in
memory. We've graduated beyond those barbarous days by explicitly noting
the length of each string in the header, so let's just reuse that idea!
Behold, Rust's new string literals:

    fn main() {
        print(#7"hello");
        print(#2", ");
        print(#5"world");
    }

</facetious>


On Sun, Sep 22, 2013 at 5:32 PM, Sebastian Sylvan <
sebastian.syl...@gmail.com> wrote:

>
>
>
> On Thu, Sep 19, 2013 at 1:36 PM, Kevin Ballard <ke...@sb.org> wrote:
>
>> One feature common to many programming languages that Rust lacks is "raw"
>> string literals.
>
>
> This is one of those things where I feel almost all languages get wrong,
> and probably mostly for historical reasons. IMO there should *only* be raw
> string literals on the syntax level. It seems extremely weird to me that
> languages have this second-level language that gets interpreted within a
> literal. That kind of higher level processing should be part of a
> formatting library (e.g. a macro like fmt), rather than an embedded
> language inside the literal syntax. So, I think string literals should
> contain exactly what they contain in their source form, without any
> additional processing. If you want to express characters that are
> inconvenient to type, you can use control sequences and a (standard)
> formatting library to produce them.
>
> --
> Sebastian Sylvan
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to