[phobos] substring for std.metastrings

Philippe Sigaud philippe.sigaud at gmail.com
Mon Mar 1 00:05:17 PST 2010


> >2- the .found necessary to get the result could be hidden with a
> two-levels template:
> >auto s = substring!("fun with gun", "run");
> I try to comply to the style of std.metastrigns, they do not do it there.
>

They do that for parsing, because you have to 'return' both the value and
the rest and you can't do both the eponymous trick and declare another
'.something' at the same time.
Format becomes the formatted string without an intermediary '.format'
For substring, I think a boolean is the only thing you want. But you may
want to return the rest also. ie, your template consumes the string until it
founds the substring.


> And when I see "auto s = substring!("fun with gun", "run");" I presume s is
> substring, not
> boolean.
>

Yeah me too at first sight, but then you already know the substring: it's
"run"...
You could call it "contains":   auto c = contains!(bigstring, smallstring);


>
> I would like to hear if people think that substring deserves to be in
> std.metastrings. Otherwise all this discussion is pointless.
>
> You may not have many answers there: they are all rushing to finish D and
the most important librairies like std.concurrency.
You'll have to wait 1-2 months to have them look elsewhere.

Anyway, what usage do you see for substring?

  Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100301/5867d677/attachment.htm>


More information about the phobos mailing list