Damn, sorry. Will do.
Andrei
On 8/26/10 10:27 PDT, Steve Schveighoffer wrote:
GAH! I did it again!
Andrei, stop replying to all :)
-Steve
----- Forwarded Message ----
From: Steve Schveighoffer<[email protected]>
To: Andrei Alexandrescu<[email protected]>
Sent: Thu, August 26, 2010 1:24:43 PM
Subject: Re: [phobos] phobos commit, revision 1930
No, I want to be able to use static arrays as a buffer. This allows nifty
things like using the stack if possible, and reallocating if you go beyond the
stack buffer size.
BTW, capacity already returns 0 for these.
It's immutable *literals* that I want to disallow. Can we get a function to
determine if a string is a literal vs a stack or heap-allocated value?
On that topic a bit, calling clear on an Appender!string allows you to
overwrite
immutable data. Do we care too much? I think we can just mark the clear
function as @system and call it a day...
-Steve
----- Original Message ----
From: Andrei Alexandrescu<[email protected]>
To: Discuss the phobos library for D<[email protected]>
Cc: Steve Schveighoffer<[email protected]>
Sent: Thu, August 26, 2010 1:18:25 PM
Subject: Re: [phobos] phobos commit, revision 1930
Walter, Sean, could we arrange such that capacity of static arrays
yields zero?
Andrei
On 8/26/10 10:16 PDT, Steve Schveighoffer wrote:
The constructor uses arr.capacity to determine how much it can append.
>
assumeSafeAppend will ensure that arr.capacity is as large as possible,
so
yes,
calling before creating the Appender will maximize the capacity,
regardless
of
whether it will stomp or not.
One thing that Appender will do, which is bad, but I'm not sure we need
to
care,
it can be given a string literal, and then try to write over the string
literal
like this:
>
auto app = appender("hello");
// app.put('c'); // this would be ok
app.clear();
app.put('c'); // segfault on Linux
I'm not sure how to get around this. I thought of checking the heap to
see
if
it owns the pointer, but then you disallow useful things like using a
stack-allocated buffer. I think this case may be uncommon enough to not
care.
-Steve
From: David Simcha<[email protected]>
To: Discuss the phobos library for D<[email protected]>
>> Sent: Thu, August 26, 2010 1:10:31 PM
Subject: Re: [phobos] phobos commit, revision 1930
>> Nice work. One small question/possible feature request, though: Will
calling
assumeSafeAppend() on an array before constructing an Appender using it
prevent
>
it from being reallocated on the first append? If not, can Appender
have
some
kind of assumeSafeAppend workaround in it?
> _______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos