On 10/07/14 22:47, Marc Schütz schue...@gmx.net wrote:
No, this is equivalent to:
void bar (string a)
{
assert(a is GET);
}
void asd()
{
bar(GET);
}
Enums behave as if their values are copy-n-pasted everywhere they are
used (you probably know that).
Yes, I was thinking that. Then
On 10/07/14 22:48, anonymous wrote:
I don't think this is a bug.
Remember that enums have copy-paste semantics. So, this is the
same as comparing literals from different modules. Apparently, in
the same module, a duplicate string literal is optimized out. But
that's not done across the module
On 10/07/14 23:48, Marc Schütz schue...@gmx.net wrote:
Try other immutable variables (int arrays, structs), and non-immutable
ones. They will probably behave differently.
String literals are put directly in the executable and therefore should
be the same. Array literals are dynamically
How can i get the number of items which are currently hold in a
DList?
pgtkda:
How can i get the number of items which are currently hold in a
DList?
Try (walkLength is from std.range):
mydList[].walkLength
Bye,
bearophile
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote:
Phobos algorithms use ranges. The following is what I've come
up with very quickly:
Thx
On Thursday, 10 July 2014 at 12:12:20 UTC, Marc Schütz wrote:
On Wednesday, 9 July 2014 at 15:09:08 UTC, Chris wrote:
On Wednesday, 9 July 2014 at 15:00:25 UTC, seany wrote:
I apologize many times for this question, may be this had
already been answered somewhere, but considering today the
On Wednesday, 9 July 2014 at 07:43:57 UTC, Ali Çehreli wrote:
Ali
This
https://github.com/nordlow/justd/blob/master/random_ex.d
is what I have so far. Does this look ok to you?
Question: Can I somehow avoid the duplication of logic in
- auto ref randInPlace(R)(R x) @safe if
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio
wrote:
A code I'm working on stops working and starts printing an
infinite loop of
core.exception.InvalidMemoryOperationError
to the command line output. The code is quite complex and the
bug seems to present itself almost in
On 7/11/14, 4:46 AM, bearophile wrote:
pgtkda:
How can i get the number of items which are currently hold in a DList?
Try (walkLength is from std.range):
mydList[].walkLength
Bye,
bearophile
So the doubly linked list doesn't know it's length? That seems a bit
inefficient...
Ary Borenszweig:
So the doubly linked list doesn't know it's length? That seems
a bit inefficient...
Have you tried to compile mydList.length or mydList[].length? If
both don't compile, then you have to walk the items.
Walking the items is not efficient, but:
- Linked lists are very
On Fri, Jul 11, 2014 at 10:23:58AM -0300, Ary Borenszweig via
Digitalmars-d-learn wrote:
On 7/11/14, 4:46 AM, bearophile wrote:
pgtkda:
How can i get the number of items which are currently hold in a
DList?
Try (walkLength is from std.range):
mydList[].walkLength
Bye,
bearophile
Tried to compile on linux, got this error message (I guess I can
fix it):
dmd -c textgen.d
textgen.d(36): Error: cannot implicitly convert expression
(DMDScript fatal runtime error: ) of type string to char[]
textgen.d(36): Error: cannot implicitly convert expression (0) of
type int to char[]
On Friday, 11 July 2014 at 11:43:44 UTC, Joakim wrote:
On Thursday, 10 July 2014 at 15:36:53 UTC, francesco cattoglio
wrote:
A code I'm working on stops working and starts printing an
infinite loop of
core.exception.InvalidMemoryOperationError
to the command line output. The code is quite
Is there a trait to check if a type is a
- value type (struct, static array, etc)
- reference type (class, dynamic array, string, etc)
?
On Friday, 11 July 2014 at 16:10:31 UTC, Nordlöw wrote:
Is there a trait to check if a type is a
- value type (struct, static array, etc)
- reference type (class, dynamic array, string, etc)
?
There's http://dlang.org/phobos/std_traits.html#hasIndirections
Note that structs and static
On 07/11/2014 03:38 AM, Nordlöw wrote:
https://github.com/nordlow/justd/blob/master/random_ex.d
is what I have so far. Does this look ok to you?
The following seems redundant because the other isFloatingPoint!E
version uses the default arguments 0 and 1 anyway.
auto ref randInPlace(E)(ref
@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 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
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
http://forum.dlang.org/thread/pxotrowaqcenrpnnw...@forum.dlang.org
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
On Thursday, 10 July 2014 at 19:33:15 UTC, simendsjo wrote:
On 07/10/2014 06:05 PM, Alexandre wrote:
I have a string X and I need to insert a char in that string...
auto X = 100;
And I need to inser a ',' in position 3 of this string..., I
try to use
the array.insertInPlace,
I'm new to D. I've been using C since it was a baby and C++ back
when it was only a pre-compiler for c. So, I may just be stuck
thinking in C land.
The issue is I am attempting to use the version(unittest)
feature. However the compiler pukes up the error below. I'm sure
it's something easy
On 12/07/2014 5:08 p.m., dysmondad wrote:
I'm new to D. I've been using C since it was a baby and C++ back when it
was only a pre-compiler for c. So, I may just be stuck thinking in C land.
The issue is I am attempting to use the version(unittest) feature.
However the compiler pukes up the
On 07/11/2014 10:08 PM, dysmondad wrote:
class Velocity
{
[...]
ref Velocity opOpAssign(string op) ( in float multiplier )
Unrelated to your question, you want to return just Velocity there.
Unlike C++, classes are reference types in D. So, Velocity itself is
essentially a Velocity*
26 matches
Mail list logo