On Friday, 11 July 2014 at 21:02:30 UTC, Timon Gehr wrote:
He is allocating an immutable(int)[] here. There is no reason
why it should allocate unless providing different addresses for
different runs of the code is considered a feature, as the
literal has a compile-time known value. It's just t
http://forum.dlang.org/thread/pxotrowaqcenrpnnw...@forum.dlang.org
On 07/11/2014 10:39 PM, Dicebot wrote:
Key difference is that type of string literal is immutable(char)[] so it
is perfectly legal to keep it in binary text segment. Type of array
literal is just T[] (int[] here) and you can possibly mutate their
elements. Because of this each assignment of array
Key difference is that type of string literal is
immutable(char)[] so it is perfectly legal to keep it in binary
text segment. Type of array literal is just T[] (int[] here) and
you can possibly mutate their elements. Because of this each
assignment of array literal needs to allocate a new copy
On Friday, 11 July 2014 at 20:02:32 UTC, Weasel wrote:
Why does the s1 not throw an error, but the a1 does?
Strings don't allocate upon use whereas all other arrays do
unless you specifically mark it as static - immutability isn't
considered here (I think because the part of the compiler that
@nogc
void main(string[] args)
{
immutable(char)[] s1 = "hello";
immutable(int)[] a1 = [1, 2];
}
Why does the s1 not throw an error, but the a1 does? As far as I
can tell, they're both immutable arrays.
Error is: "Error: array literal @nogc function main may cause GC
allocation"
It
On Tuesday, 20 May 2014 at 21:48:08 UTC, Timon Gehr wrote:
Wtf. Is this really the point you are trying to make? :o)
This achieves the same:
template lookupTable(alias fn,uint max=255){
static assert(maxenum ReturnType!fn[max+1]
lookupTable=iota(0,max+1).map!fn.array;
}
Ha! That's .
On 05/20/2014 11:48 PM, Timon Gehr wrote:
This achieves the same:
template lookupTable(alias fn,uint max=255){
static assert(max
(Though I'd never actually do template argument checking in a static
assert within the template body.)
On 05/20/2014 11:04 PM, anonymous wrote:
On Tuesday, 20 May 2014 at 20:15:09 UTC, Dominikus Dittes Scherkl
wrote:
/// create a fixed size array with the given name and with *max* entries
max + 1 entries
/// of immutable values of the same type as the return value of the
/// given function.
/
On Tuesday, 20 May 2014 at 21:16:26 UTC, monarch_dodra wrote:
enum ReturnType!fn[length] lookupTable = [elements];
Depending on what the usecase is, you might want to change that
to static immutable instead:
static immutable ReturnType!fn[length] lookupTable = [elements];
Remember that
On Tuesday, 20 May 2014 at 21:04:37 UTC, anonymous wrote:
On Tuesday, 20 May 2014 at 20:15:09 UTC, Dominikus Dittes
Scherkl
wrote:
/// create a fixed size array with the given name and with
*max* entries
max + 1 entries
/// of immutable values of the same type as the return value
of the
//
On Tuesday, 20 May 2014 at 20:15:09 UTC, Dominikus Dittes Scherkl
wrote:
/// create a fixed size array with the given name and with
*max* entries
max + 1 entries
/// of immutable values of the same type as the return value of
the
/// given function.
/// it contains the values of that functio
On Tuesday, 20 May 2014 at 17:14:31 UTC, John Colvin wrote:
On Tuesday, 20 May 2014 at 12:25:11 UTC, Dominikus Dittes
Scherkl wrote:
Did I understand correct that a function can only be @nogc if
also all functions that it calls are @nogc too (and of course
it doesn't use the GC itself)?
If so
On Tuesday, 20 May 2014 at 12:25:11 UTC, Dominikus Dittes Scherkl
wrote:
Did I understand correct that a function can only be @nogc if
also all functions that it calls are @nogc too (and of course
it doesn't use the GC itself)?
If so, should this be possible:
string foo()
{
// use GC to al
On Tuesday, 20 May 2014 at 12:25:11 UTC, Dominikus Dittes Scherkl
wrote:
Did I understand correct that a function can only be @nogc if
also all functions that it calls are @nogc too (and of course
it doesn't use the GC itself)?
If so, should this be possible:
string foo()
{
// use GC to al
Did I understand correct that a function can only be @nogc if
also all functions that it calls are @nogc too (and of course it
doesn't use the GC itself)?
If so, should this be possible:
string foo()
{
// use GC to allocate some string
}
bar @nogc
{
mixin(foo());
}
Because, bar() didn'
16 matches
Mail list logo