Re: associative arrays

2012-01-09 Thread Kapps
Looks like this is fixed for 2.058. https://github.com/D-Programming-Language/dmd/commit/3e23b0f5834acb32eaee20d88c30ead7e03bb2f4 On 08/01/2012 3:43 AM, Jonathan M Davis wrote: On Sunday, January 08, 2012 03:24:22 Kapps wrote: Ah, found the bug / pull request.

Re: associative arrays

2012-01-09 Thread dennis luehring
assert(key in aa); aa.remove(key); So, as far as I can tell, the current situation is more efficient, and it doesn't cost you any expressiveness. You can still have an exception thrown when remove fails if you use enforce before the call if you want an exception thrown when the element isn't

Re: An issue with lazy delegates

2012-01-09 Thread Stewart Gordon
On 05/01/2012 05:26, Andrej Mitrovic wrote: snip The first call doesn't do anything because the delegate is wrapped inside of another delegate. I want this template to be versatile enough to be used by both lazy expressions and delegate literals, but I don't know how. snip If you have a

Learning With D

2012-01-09 Thread hope
http://www.digitalmars.com/d/archives/digitalmars/D/announce/Learning_With_D_20566.html any new news about it? it is a very nice tutorial

Re: Ref local variables?

2012-01-09 Thread Steven Schveighoffer
On Sun, 08 Jan 2012 12:54:13 -0500, Ben Davis ent...@cantab.net wrote: Hi, Is there a reason 'ref' is disallowed for local variables? I want to write something like: MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; My actual case is more

Re: associative arrays

2012-01-09 Thread Steven Schveighoffer
On Sun, 08 Jan 2012 08:40:27 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Sunday, January 08, 2012 14:24:32 simendsjo wrote: Thanks for your clarifications. Does this mean even this is undefined? aa[a] = new C(); auto c = a in aa; aa[b] = new C(); // Using c here is undefined as an

Re: Ref local variables?

2012-01-09 Thread bearophile
Steven Schveighoffer: With new = syntax (in git head), this would probably be: @property ref tile = map[y*w+x]; That's not currently supported: http://d.puremagic.com/issues/show_bug.cgi?id=7176 Bye, bearophile

std.csv

2012-01-09 Thread Joshua Reusch
Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any good error messages) csv reading function ? Thank you

Re: Ref local variables?

2012-01-09 Thread Steven Schveighoffer
On Mon, 09 Jan 2012 09:27:06 -0500, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: With new = syntax (in git head), this would probably be: @property ref tile = map[y*w+x]; That's not currently supported: http://d.puremagic.com/issues/show_bug.cgi?id=7176 The given

Re: std.csv

2012-01-09 Thread simendsjo
On 09.01.2012 16:05, Joshua Reusch wrote: Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any good error messages) csv reading function ? Thank you It should be ready for production work, but if

How to get runtime args from shared static this module ctor?

2012-01-09 Thread Andrej Mitrovic
I need to get the name of the executable but without using a string[] from main. I'm wrapping a 3rd party library that requires me to initialize it by calling an extern function to pass the executable name. However I don't want to force the user to pass args from main when constructing a class,

Re: How to get runtime args from shared static this module ctor?

2012-01-09 Thread Joshua Reusch
Am 09.01.2012 18:00, schrieb Andrej Mitrovic: I need to get the name of the executable but without using a string[] from main. I'm wrapping a 3rd party library that requires me to initialize it by calling an extern function to pass the executable name. However I don't want to force the user to

Re: associative arrays

2012-01-09 Thread Jonathan M Davis
On Monday, January 09, 2012 09:25:14 Steven Schveighoffer wrote: Actually, not invalid for the current implementation. I don't know if it's stated whether an AA specifically requires that elements do not re-associate on a rehash. Well, like I said, it depends on the current implementation.

Re: How to get runtime args from shared static this module ctor?

2012-01-09 Thread Andrej Mitrovic
Sweeet, thanks Joshua! On 1/9/12, Joshua Reusch yos...@arkandos.de wrote: Am 09.01.2012 18:00, schrieb Andrej Mitrovic: I need to get the name of the executable but without using a string[] from main. I'm wrapping a 3rd party library that requires me to initialize it by calling an extern

Re: std.csv

2012-01-09 Thread Joshua Reusch
Am 09.01.2012 16:19, schrieb simendsjo: On 09.01.2012 16:05, Joshua Reusch wrote: Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any good error messages) csv reading function ? Thank you It

Re: associative arrays

2012-01-09 Thread Andrej Mitrovic
On 1/9/12, Steven Schveighoffer schvei...@yahoo.com wrote: BTW, dcollections' HashMap, HashSet, and HashMultiset do guarantee that adding elements does not invalidated cursors (dcollections' safe version of pointers) as long as you use the default Hash implementation. However, I just noticed

Re: associative arrays

2012-01-09 Thread Steven Schveighoffer
On Mon, 09 Jan 2012 13:35:26 -0500, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 1/9/12, Steven Schveighoffer schvei...@yahoo.com wrote: BTW, dcollections' HashMap, HashSet, and HashMultiset do guarantee that adding elements does not invalidated cursors (dcollections' safe version of

How do you overload new and delete for a class?

2012-01-09 Thread Adrian Mercieca
Hi, Can someone please provide an example regarding overloading new and delete for a class? Thanks a lot.

Re: Learning With D

2012-01-09 Thread Ali Çehreli
On 01/09/2012 05:41 AM, hope wrote: http://www.digitalmars.com/d/archives/digitalmars/D/announce/Learning_With_D_20566.html any new news about it? it is a very nice tutorial I hope it has actually grown but we haven't heard the news yet! :) On a related note, I am continuing to translate

Re: associative arrays

2012-01-09 Thread Andrej Mitrovic
Ok, allow me to temporarily hijack again and ask: Would you mind adding opIn_r (or rather the newer opBinaryRight with in) that forwards to contains() for the HashSet and similar hash-based classes that define contains()? It would make porting code that uses builtin hashes to your own

Re: associative arrays

2012-01-09 Thread Steven Schveighoffer
On Mon, 09 Jan 2012 14:57:36 -0500, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: Ok, allow me to temporarily hijack again and ask: Would you mind adding opIn_r (or rather the newer opBinaryRight with in) that forwards to contains() for the HashSet and similar hash-based classes that

Re: associative arrays

2012-01-09 Thread Andrej Mitrovic
On 1/9/12, Steven Schveighoffer schvei...@yahoo.com wrote: Could this be you? Ah, yes. I didn't even notice you've replied to that, sorry. Yes, I'm ok with it.

Re: associative arrays

2012-01-09 Thread Manfred Nowak
dennis luehring wrote: why is there an exception/error neeeded if missing? Exceptions or errors are not _needed_. Their existence stems from the modell under which the user of the operation _has_ to think about the operation, especially whether it is a:only the outcome of the operation or

Exceptions in safe D

2012-01-09 Thread Robert Clipsham
Are exceptions in safe D possible? I started trying to make my code @safe (there's no reason why it can't be as far as I'm aware), but I hit the following issue: @safe class MyException : Exception { this() { super(); } } void main() { throw new MyException(); }

Re: Exceptions in safe D

2012-01-09 Thread Juan Campanas
On Monday, 9 January 2012 at 21:14:05 UTC, Robert Clipsham wrote: Are exceptions in safe D possible? I started trying to make my code @safe (there's no reason why it can't be as far as I'm aware), but I hit the following issue: @safe class MyException : Exception { this() {

Waiting around

2012-01-09 Thread Joshua Niehus
Hello, I need to connect to a network location and read a file but I also need some way of waiting around until the connection is established. Currently I use the following snippet to do this: while (!std.file.exists(/Volumes/mountedDir/myfile.txt) timeout 30) {

Re: Exceptions in safe D

2012-01-09 Thread Simen Kjærås
On Mon, 09 Jan 2012 22:33:28 +0100, Juan Campanas joh...@bells.com wrote: On Monday, 9 January 2012 at 21:14:05 UTC, Robert Clipsham wrote: Are exceptions in safe D possible? I started trying to make my code @safe (there's no reason why it can't be as far as I'm aware), but I hit the

Problem with interfacing C code to D

2012-01-09 Thread bioinfornatics
Dear i do not understand why the first example works and the second segfault. Thanks EXAMPLE 1 --- // ldc2 -L=/usr/lib64/libXlib.so -L-lX11 -g -w xtest.d import std.string; import std.stdio; import std.conv; import std.c.stdlib : getenv; import std.exception :

Re: Problem with interfacing C code to D

2012-01-09 Thread Trass3r
What's the definition of Display?

Re: Problem with interfacing C code to D

2012-01-09 Thread bioinfornatics
Le mardi 10 janvier 2012 à 01:26 +0100, Trass3r a écrit : What's the definition of Display? This one: _ struct _XDisplay{ XExtData* ext_data; /* hook for extension to hang data */ _XPrivate* private1;

Re: Problem with interfacing C code to D

2012-01-09 Thread Andrej Mitrovic
It's likely a module Gmail - Problem with interfacing C code to D - Mozilla Firefo; import std.algorithm; import std.array; import std.stdio; void main() { } On 1/10/12, bioinfornatics bioinfornat...@fedoraproject.org wrote: Le mardi 10 janvier 2012 à 01:26 +0100, Trass3r a écrit : What's

Re: Problem with interfacing C code to D

2012-01-09 Thread Andrej Mitrovic
Jesus christ, sorry about that my keyboard script went crazy and posted that. What I was going to say is it's likely a mismatch of the struct sizes. In the second example you are dereferencing the pointer on the D size, which does a field-by-field copy of the pointed-to struct. But D will only

Re: Problem with interfacing C code to D

2012-01-09 Thread Artur Skawina
On 01/10/12 01:02, bioinfornatics wrote: Dear i do not understand why the first example works and the second segfault. Thanks EXAMPLE 1 --- Display* display = XOpenDisplay(getenv(DISPLAY)); char** fonts = XListFonts( display, pattern.dup.ptr, 10,

Re: Problem with interfacing C code to D

2012-01-09 Thread Andrej Mitrovic
Scratch that, in X11 apparently the Display structure is an incomplete type (so sizeof won't work). This means you most probably *have* to use pass it around as an opaque pointer. It's kind of odd because you can still access some of its fields (so it's not totally opaque), but you can't do

Re: Exceptions in safe D

2012-01-09 Thread Jesse Phillips
Maybe I missed something, but the last I knew Safe D is not completely implemented. I think checking that you don't call system functions is the only piece implemented, and Phobos isn't annotated with it.

Re: Exceptions in safe D

2012-01-09 Thread Jonathan M Davis
On Tuesday, January 10, 2012 03:55:35 Jesse Phillips wrote: Maybe I missed something, but the last I knew Safe D is not completely implemented. I think checking that you don't call system functions is the only piece implemented, and Phobos isn't annotated with it. Yeah. I'm not sure how well

Re: std.csv

2012-01-09 Thread Jesse Phillips
On Monday, 9 January 2012 at 15:05:53 UTC, Joshua Reusch wrote: Hello, I checked out the phobos git repo and found a std.csv module. Is it ready to use or should I stay to my own (but incomplete and whithout any good error messages) csv reading function ? Thank you Yep, no known reason it

Re: Learning With D

2012-01-09 Thread Jesse Phillips
On Monday, 9 January 2012 at 13:41:08 UTC, hope wrote: http://www.digitalmars.com/d/archives/digitalmars/D/announce/Learning_With_D_20566.html any new news about it? it is a very nice tutorial Hi, it is still on my plate, but hasn't seen a lot of progress. One major point is that I don't

Re: How do you overload new and delete for a class?

2012-01-09 Thread Adrian Mercieca
Hi Alex, Thanks for the answer. As for the allocation, you mention malloc: is that malloc from the C runtime library? You also imply alternatives to this allocator; what would these be? As for deletion, does on then invoke delete on the malloc'ed data pointer? Pointing me to some example

Re: associative arrays

2012-01-09 Thread dennis luehring
Am 09.01.2012 22:08, schrieb Manfred Nowak: dennis luehring wrote: why is there an exception/error neeeded if missing? Exceptions or errors are not _needed_. Their existence stems from the modell under which the user of the operation _has_ to think about the operation, especially whether it