On 05/02/2013 16:39, bearophile wrote:
Nick Treleaven:
^ I know you're aware of this, but maybe others might not know the
default-argument alloca wrapping trick:
For some usages it's an improvement over raw usage of alloca.
I did see this in past, but sometimes I forget.
Sorry if I sounded
On 05/02/2013 22:15, monarch_dodra wrote:
On Tuesday, 5 February 2013 at 21:14:32 UTC, Nick Treleaven wrote:
On 05/02/2013 21:13, Nick Treleaven wrote:
I've just tried it with dmd 2.059 (haven't upgraded yet)
sorry, 2.060
Right, it's "alias" being finicky, because "args.length" isn't an act
On Tuesday, 5 February 2013 at 21:14:32 UTC, Nick Treleaven wrote:
On 05/02/2013 21:13, Nick Treleaven wrote:
I've just tried it with dmd 2.059 (haven't upgraded yet)
sorry, 2.060
Right, it's "alias" being finicky, because "args.length" isn't an
actual variable (it's a property). The proble
On 05/02/2013 21:13, Nick Treleaven wrote:
I've just tried it with dmd 2.059 (haven't upgraded yet)
sorry, 2.060
On 05/02/2013 21:02, monarch_dodra wrote:
On Tuesday, 5 February 2013 at 20:47:46 UTC, Nick Treleaven wrote:
On 05/02/2013 16:47, monarch_dodra wrote:
T[] stack(T, alias N)(void* m = alloca(T.sizeof * N))
{
return (cast(T*)m)[0 .. N];
}
This works if you know N at compile-time. But there
On Tuesday, 5 February 2013 at 20:47:46 UTC, Nick Treleaven wrote:
On 05/02/2013 16:47, monarch_dodra wrote:
On Tuesday, 5 February 2013 at 16:37:41 UTC, Nick Treleaven
wrote:
I've just realized this doesn't work for variable-length
allocation:
T[] stack(T)(size_t N, void* m = alloca(T.sizeof
On 05/02/2013 16:47, monarch_dodra wrote:
On Tuesday, 5 February 2013 at 16:37:41 UTC, Nick Treleaven wrote:
I've just realized this doesn't work for variable-length allocation:
T[] stack(T)(size_t N, void* m = alloca(T.sizeof * N))
Error: undefined identifier N, did you mean alias T?
N is no
Why not:
[code]
T[] stack(T, const size_t N)(void* m = alloca(T.sizeof * N))
{
return (cast(T*)m)[0 .. N];
}
[/code]
?
On Tuesday, 5 February 2013 at 16:37:41 UTC, Nick Treleaven wrote:
On 05/02/2013 16:17, Nick Treleaven wrote:
On 03/02/2013 13:22, bearophile wrote:
Era Scarecrow:
On Sunday, 3 February 2013 at 09:11:59 UTC, Namespace wrote:
Sure, but alloca has the same ugly interface as malloc. :/
You me
Nick Treleaven:
^ I know you're aware of this, but maybe others might not know
the default-argument alloca wrapping trick:
For some usages it's an improvement over raw usage of alloca.
I did see this in past, but sometimes I forget.
Bye,
bearophile
On 05/02/2013 16:17, Nick Treleaven wrote:
On 03/02/2013 13:22, bearophile wrote:
Era Scarecrow:
On Sunday, 3 February 2013 at 09:11:59 UTC, Namespace wrote:
Sure, but alloca has the same ugly interface as malloc. :/
You mean that you have to specify how many raw bytes you want, then
cast
On 03/02/2013 13:22, bearophile wrote:
Era Scarecrow:
On Sunday, 3 February 2013 at 09:11:59 UTC, Namespace wrote:
Sure, but alloca has the same ugly interface as malloc. :/
You mean that you have to specify how many raw bytes you want, then
cast it to what you need? I never thought alloca
12 matches
Mail list logo