Re: How to Instantiate struct defined in template

2012-09-22 Thread Craig Dillabaugh
On Sunday, 23 September 2012 at 04:51:31 UTC, Jonathan M Davis wrote: On Sunday, September 23, 2012 06:37:30 Craig Dillabaugh wrote: One question. Is there any way to get the function template to deduce the type of T from the vertices I pass, so that I can call: euclid_dist(v1, v2) ) instead o

Re: How to Instantiate struct defined in template

2012-09-22 Thread Jonathan M Davis
On Sunday, September 23, 2012 06:37:30 Craig Dillabaugh wrote: > One question. Is there any way to get the function template to > deduce the type of T from the vertices I pass, so that I can > call: > > euclid_dist(v1, v2) ) > > instead of: > > euclid_dist!float(v1, v2) ); It should infer the t

Re: How to Instantiate struct defined in template

2012-09-22 Thread Craig Dillabaugh
On Sunday, 23 September 2012 at 04:03:28 UTC, Jonathan M Davis wrote: On Sunday, September 23, 2012 05:49:06 Craig Dillabaugh wrote: Hello, clip Before anything, I'd question why you declared vt at all. If all you're putting in it is a single struct, then just templatize the struct direct

Re: How to Instantiate struct defined in template

2012-09-22 Thread Jonathan M Davis
On Sunday, September 23, 2012 05:49:06 Craig Dillabaugh wrote: > Hello, > I am trying to figure out how templates work and tried to define > the > following template to define vertices of any dimension and > operations > on them. > > import std.stdio; > import std.random; > import std.range; > imp

How to Instantiate struct defined in template

2012-09-22 Thread Craig Dillabaugh
Hello, I am trying to figure out how templates work and tried to define the following template to define vertices of any dimension and operations on them. import std.stdio; import std.random; import std.range; import std.conv; import std.math; /* * T must be one of the floating point types *

Re: Testing for template argument being result of takeExactly

2012-09-22 Thread Jonathan M Davis
On Sunday, September 23, 2012 02:57:36 bearophile wrote: > Jonathan M Davis: > > So, clearly I don't have the is expression right, and this is > > seriously pushing the edge of my knowledge of is expressions. > > So, any help would be appreciated. Thanks. > > I have done some tries, but I have fai

Re: Testing for template argument being result of takeExactly

2012-09-22 Thread bearophile
Jonathan M Davis: So, clearly I don't have the is expression right, and this is seriously pushing the edge of my knowledge of is expressions. So, any help would be appreciated. Thanks. I have done some tries, but I have failed, I am sorry :-) The is() syntax is a part of D good to burn on a c

Testing for template argument being result of takeExactly

2012-09-22 Thread Jonathan M Davis
I'm trying to test whether a template argument is the type returned by takeExactly, and I haven't been able to sort out the template voodoo required yet. It would be a lot easier if I had a variable to work with, but I just have the type, and the fancy is expression required to pull it off is fa

Re: system vs. execvp ?

2012-09-22 Thread Peter Sommerfeld
Jonathan M Davis wrote: Peter Sommerfeld wrote: This works as expected: string cmd = "dmd src/xyz.d"; int i = system(cmd); But this not: string[] cmd; cmd ~= "src/xyz.d"; int i = execvp("dmd",cmd); Of course, dmd is in PATH (Win7). What is wrong here? Please elaborate on w

Re: system vs. execvp ?

2012-09-22 Thread Andrej Mitrovic
On 9/23/12, Jonathan M Davis wrote: > I'd be very surprised if you were correct about this. I was wrong, it's for a different reason: http://stackoverflow.com/questions/3027320/why-first-arg-to-execve-must-be-path-to-executable

Re: system vs. execvp ?

2012-09-22 Thread Jonathan M Davis
On Saturday, September 22, 2012 16:10:11 Jonathan M Davis wrote: > Now, looking at the docs for std.process.execvp, they seem to think that the > exec functions are going to return, but that's not what the man pages for > the C functions (which they're calling) say, nor is it how they behave. The

Re: system vs. execvp ?

2012-09-22 Thread Jonathan M Davis
On Sunday, September 23, 2012 01:12:34 Andrej Mitrovic wrote: > On 9/23/12, Peter Sommerfeld wrote: > > What is wrong here? > > string[] cmd; > cmd ~= "dmd"; > cmd ~= "src/xyz.d"; > int i = execvp("dmd",cmd); > > 1st arg should always be the app name, even though apps typically > ignore/

Re: system vs. execvp ?

2012-09-22 Thread Andrej Mitrovic
On 9/23/12, Peter Sommerfeld wrote: > What is wrong here? string[] cmd; cmd ~= "dmd"; cmd ~= "src/xyz.d"; int i = execvp("dmd",cmd); 1st arg should always be the app name, even though apps typically ignore/skip the first arg.

Re: system vs. execvp ?

2012-09-22 Thread Jonathan M Davis
On Sunday, September 23, 2012 00:53:48 Peter Sommerfeld wrote: > Hi! > > This works as expected: > >string cmd = "dmd src/xyz.d"; >int i = system(cmd); > > But this not: > >string[] cmd; >cmd ~= "src/xyz.d"; >int i = execvp("dmd",cmd); > > Of course, dmd is in PATH (Win7)

system vs. execvp ?

2012-09-22 Thread Peter Sommerfeld
Hi! This works as expected: string cmd = "dmd src/xyz.d"; int i = system(cmd); But this not: string[] cmd; cmd ~= "src/xyz.d"; int i = execvp("dmd",cmd); Of course, dmd is in PATH (Win7). What is wrong here? tia Peter

Re: object.error: Privileged Instruction

2012-09-22 Thread Ali Çehreli
On 09/22/2012 11:33 AM, simendsjo wrote: > assert(false, "aoeu"); // with message, object.error: Privileged Yep, Dvorak keyboard rules! ;) Ali

Re: object.error: Privileged Instruction

2012-09-22 Thread Jonathan M Davis
On Saturday, September 22, 2012 21:19:27 Maxim Fomin wrote: > Privilege instruction is an assembly instruction which can be > executed only at a certain executive process context, typically > os kernel. AFAIK assert(false) was claimed to be implemented by > dmd as a halt instruction, which is privi

Re: object.error: Privileged Instruction

2012-09-22 Thread Maxim Fomin
Privilege instruction is an assembly instruction which can be executed only at a certain executive process context, typically os kernel. AFAIK assert(false) was claimed to be implemented by dmd as a halt instruction, which is privileged one. However, compiled code shows that dmd generates int

object.error: Privileged Instruction

2012-09-22 Thread simendsjo
What does the message in the subject mean? Here's a testcase (tested on dmd 2.060 on win7 32-bit): import core.exception; import core.runtime; // comment out this, and no stacktrace is printed void myAssertHandler(string file, size_t line, string msg = null) { } static this() { setAsse

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 22.9.2012 13:50, Johannes Pfau wrote: >> 1. Declare it as "shared" > There's also __gshared. Yup, that works. Thanks

Re: Passing associative array to another thread

2012-09-22 Thread Johannes Pfau
Am Sat, 22 Sep 2012 12:30:30 +0200 schrieb Jacob Carlborg : > On 2012-09-22 11:24, Martin Drasar wrote: > > > thanks for the hint. Making it shared sounds a bit fishy to me. My > > intention is to pass some read only data, that are in fact thread > > local and there is no real need to make them s

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 22.9.2012 13:19, Jonathan M Davis wrote: > The problem with immutable is probably due to this bug: > > http://d.puremagic.com/issues/show_bug.cgi?id=5538 > > And casting to shared probably won't work due to this bug: > > http://d.puremagic.com/issues/show_bug.cgi?id=6585 > > std.variant need

Re: Passing associative array to another thread

2012-09-22 Thread Jonathan M Davis
On Saturday, September 22, 2012 12:30:30 Jacob Carlborg wrote: > Looking at your original example I don't understand why the immutable aa > won't work. That's the whole point of immutable, it's safe to share > among threads. It's probably a bug somewhere. I think someone else can > answer these que

Re: Passing associative array to another thread

2012-09-22 Thread Jacob Carlborg
On 2012-09-22 11:24, Martin Drasar wrote: thanks for the hint. Making it shared sounds a bit fishy to me. My intention is to pass some read only data, that are in fact thread local and there is no real need to make them shared. The whole point of thread local data is that it's only accessible

Re: Passing associative array to another thread

2012-09-22 Thread Martin Drasar
On 21.9.2012 19:01, Jacob Carlborg wrote: > Perhaps declaring the associative array as "shared". An alternative > would be to serialize the aa, pass it to another thread, and deserialize > it. That would though create a copy. Hi Jacob, thanks for the hint. Making it shared sounds a bit fishy to m

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > I would prefer if "super.alias" meant to take overloads of all base > classes into account. Although this would be kind of counter-intuitive since 'super' already means the direct base class.

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > Now let's say the Doo clas removes the meth overload and the alias: Sorry that should be "the Bar class".

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Andrej Mitrovic wrote: > using the alias But I do think this can be further improved in the language. Take this for example: import std.stdio; class Foo { void meth(double) { writeln("Foo.meth"); } } class Bar : Foo { alias super.meth meth; void meth(int) { writeln("Bar

Re: how is this considered hiding methods?

2012-09-22 Thread Andrej Mitrovic
On 9/22/12, Jonathan M Davis wrote: > But why the compiler would now require that you do that, I > don't know. If that's the way that thnigs currently are, it starts to become > a bit odd that the base class functions aren't automatically available. http://dlang.org/hijack.html There's a good re

Re: how is this considered hiding methods?

2012-09-22 Thread Jonathan M Davis
On Saturday, September 22, 2012 09:49:04 Gor Gyolchanyan wrote: > Can someone please tell me why the following code gives these > errors? > > Error: class main.BirdZoo use of main.VertebrateZoo.take(Animal > animal_) hidden by BirdZoo is deprecated > > Error: class main.ParrotZoo use of main.Vert

Re: how is this considered hiding methods?

2012-09-22 Thread Gor Gyolchanyan
On Saturday, 22 September 2012 at 07:48:02 UTC, Gor Gyolchanyan wrote: Can someone please tell me why the following code gives these errors? Error: class main.BirdZoo use of main.VertebrateZoo.take(Animal animal_) hidden by BirdZoo is deprecated Error: class main.ParrotZoo use of main.Verte

how is this considered hiding methods?

2012-09-22 Thread Gor Gyolchanyan
Can someone please tell me why the following code gives these errors? Error: class main.BirdZoo use of main.VertebrateZoo.take(Animal animal_) hidden by BirdZoo is deprecated Error: class main.ParrotZoo use of main.VertebrateZoo.take(Animal animal_) hidden by ParrotZoo is deprecated /// Th