Re: [Question] About mixin, template and alias

2013-09-22 Thread monarch_dodra
On Sunday, 22 September 2013 at 21:18:13 UTC, Michael wrote: This: // auto eventObserver = new Event!DelegateType(); // Does not do what you think it does: It *statically* initializes "eventObserver" to the *single* "new Event!DelegateType();". SO basically, all your instances are

backtrace_symbols should be called only when exception thrown

2013-09-22 Thread Timothee Cour
in src/druntime/src/core/runtime.d, backtrace_symbols is called in DefaultTraceInfo constructor. Shouldn't it be called only when exception is thrown, to speed up the case when the exception is not thrown?

Multiline String Literals without linefeeds?

2013-09-22 Thread John Carter
In C/C++ in the presence of the preprocessor a string char foo[] = "\ long\ string\ without\ linefeeds\ "; Is translated by the preprocessor to char foo[] = "longstringwithoutlinefeeds"; is there a similar mechanism in D? Or should I do... string foo = "long" "string" "without" "linefeeds" ;

Re: const and immutable members

2013-09-22 Thread Jonathan M Davis
On Monday, September 23, 2013 05:18:31 Daniel Davidson wrote: > On Sunday, 22 September 2013 at 20:17:03 UTC, Jonathan M Davis > > which can be useful > > sometimes, but in the case of a struct, it makes it so that the > > whole struct > > can't be reassigned, so it's pretty much never a good idea

Re: const and immutable members

2013-09-22 Thread Daniel Davidson
On Sunday, 22 September 2013 at 20:17:03 UTC, Jonathan M Davis wrote: If you have struct S { immutable int[] arr; } then arr can never be assigned to, so a variable of type S can never be assigned to. But if you have Yes - it (arr) can never be assigned to. That is the idea. It has alr

Re: C++ library says to delete data that it allocates

2013-09-22 Thread Jonathan M Davis
On Monday, September 23, 2013 01:12:55 w0rp wrote: > On Sunday, 22 September 2013 at 23:09:52 UTC, Charles Hixson > > wrote: > > I'm trying to use a C++ library that allocates data and returns > > a pointer to it. It tells me that I should delete the data > > when I'm through with it. > > > > Ca

Re: C++ library says to delete data that it allocates

2013-09-22 Thread w0rp
On Sunday, 22 September 2013 at 23:09:52 UTC, Charles Hixson wrote: I'm trying to use a C++ library that allocates data and returns a pointer to it. It tells me that I should delete the data when I'm through with it. Can I do this from within D? Or do I need to write some C++ code to manage

C++ library says to delete data that it allocates

2013-09-22 Thread Charles Hixson
I'm trying to use a C++ library that allocates data and returns a pointer to it. It tells me that I should delete the data when I'm through with it. Can I do this from within D? Or do I need to write some C++ code to manage the delete, and pass the pointer on to it? -- Charles Hixson

Re: join of range of ranges?

2013-09-22 Thread bearophile
monarch_dodra: As for allowing 'X'w, I think the rationale is that a cast will get you the same result (not so with string literals). OK. I have desired those char suffixes for years, so now I have written an ER: http://d.puremagic.com/issues/show_bug.cgi?id=11103 Bye, bearophile

Re: [Question] About mixin, template and alias

2013-09-22 Thread Michael
This: // auto eventObserver = new Event!DelegateType(); // Does not do what you think it does: It *statically* initializes "eventObserver" to the *single* "new Event!DelegateType();". SO basically, all your instances are sharing the same Event. I'm surprised this compiles at all,

Re: join of range of ranges?

2013-09-22 Thread Peter Alexander
On Sunday, 22 September 2013 at 18:13:39 UTC, Peter Alexander wrote: On Sunday, 22 September 2013 at 14:26:14 UTC, bearophile wrote: auto r2 = [1, 2] .map!(x => [1, 2].map!(y => '*')) .join("_"); The problem is that you are trying to map a range of range of chars

Re: [Question] About mixin, template and alias

2013-09-22 Thread monarch_dodra
On Sunday, 22 September 2013 at 18:31:20 UTC, Michael wrote: /// fire.d import std.stdio; alias void delegate() EventHandler; class Event(T) { private T[] _events; public void opOpAssign(string op)(T param) if (op == "~") { writeln(param.funcptr); _events ~= pa

Re: join of range of ranges?

2013-09-22 Thread monarch_dodra
On Sunday, 22 September 2013 at 20:27:01 UTC, bearophile wrote: Peter Alexander: The problem is that you are trying to map a range of range of chars with a range of dchars. auto r2 = [1, 2] .map!(x => [1, 2].map!(y => cast(dchar)'*')) .join("_"); This works. I see

Re: const and immutable members

2013-09-22 Thread anonymous
On Sunday, 22 September 2013 at 16:15:09 UTC, Daniel Davidson wrote: [...] 3) Also, is storing immutable(STUFF) in a struct in the general case (as opposed to just this one) useful or silly? [...] I don't really understand the _tail-const_, _tail-immutable_ argument. Why is _tail-const_ f

Re: join of range of ranges?

2013-09-22 Thread bearophile
Peter Alexander: The problem is that you are trying to map a range of range of chars with a range of dchars. auto r2 = [1, 2] .map!(x => [1, 2].map!(y => cast(dchar)'*')) .join("_"); This works. I see, thank you. When I ask a question it seems my brain switches

Re: core.sys.posix.unistd link error

2013-09-22 Thread Ruslan Mullakhmetov
Thanks. I suspected it but i wanted a formal reference. the logic, though little bit cleared by you is quite obvious. But don't waste time, if you can not tell from a scratch that this is clause x.y.z of the Standard, sorry, Book. On Sunday, 22 September 2013 at 19:56:36 UTC, Jonathan M Dav

Re: const and immutable members

2013-09-22 Thread Jonathan M Davis
On Sunday, September 22, 2013 18:15:08 Daniel Davidson wrote: > In this thread > (http://forum.dlang.org/thread/uvhwkgljavskqfueq...@forum.dlang.org) > > I asked this: > >> 3) Also, is storing immutable(STUFF) in a struct in the general > >> case (as opposed to just this one) useful or silly? > >

Re: core.sys.posix.unistd link error

2013-09-22 Thread Ruslan Mullakhmetov
I would be curious to see why you believe them to be the same. Cause i'm a C++ programmer and there is no such thing as module and module initializer, in fact object file initialization consist of initialization of all its static variables somewhen before the first call of a function in tha

Re: core.sys.posix.unistd link error

2013-09-22 Thread Jonathan M Davis
On Sunday, September 22, 2013 13:52:54 Ruslan Mullakhmetov wrote: > But now i need to sort out what the difference between > // global scope > > int a = 10; That directly initializes the variable at compile time, meaning that whatever is used to initialize the variable must be callable at compil

Re: core.sys.posix.unistd link error

2013-09-22 Thread Dmitry Olshansky
22-Sep-2013 15:52, Ruslan Mullakhmetov пишет: I found where the problem is. I used a system call (external C function) in class ctor. then I declared global variable of this class and INITIALZIED that variable inplace. If i move initalization in module static this() everything compiles. the co

Re: [OT] Pathfinding algorithm

2013-09-22 Thread Ivan Kazmenko
On Saturday, 21 September 2013 at 15:49:00 UTC, rasmus svensson wrote: Assuming the shortest path from from all nodes to every other node is already pre-computed: What is a fast algorithm to update all paths, if one node is marked as inpassible. Any good 3rd party library or research paper o

[Question] About mixin, template and alias

2013-09-22 Thread Michael
/// fire.d import std.stdio; alias void delegate() EventHandler; class Event(T) { private T[] _events; public void opOpAssign(string op)(T param) if (op == "~") { writeln(param.funcptr); _events ~= param; } public void opCall(ParamType ...)(ParamType pa

Re: join of range of ranges?

2013-09-22 Thread Peter Alexander
On Sunday, 22 September 2013 at 14:26:14 UTC, bearophile wrote: auto r2 = [1, 2] .map!(x => [1, 2].map!(y => '*')) .join("_"); The problem is that you are trying to map a range of range of chars with a range of dchars. auto r2 = [1, 2] .map!(x =>

Re: join of range of ranges?

2013-09-22 Thread bearophile
David Nadlinger: std.algorithm.joiner, or am I missing something? Something like this? (It doesn't work yet): import std.algorithm: map, joiner; import std.array: join, array; import std.string: text; void main() { string r1 = [1, 2] .map!(x => [1, 2].map!(y => '*').array

Re: cast(immutable) vs extra variable

2013-09-22 Thread Ali Çehreli
On 09/19/2013 03:07 PM, Daniel Davidson wrote: > Here is a setup: Data is coming in - say over the wire or from a > database. It is very rich data with nestings of primitives, lists and > string keyed associative arrays, recursively - think nested json. Once > a data object is read in it is passe

const and immutable members

2013-09-22 Thread Daniel Davidson
In this thread (http://forum.dlang.org/thread/uvhwkgljavskqfueq...@forum.dlang.org) I asked this: 3) Also, is storing immutable(STUFF) in a struct in the general case (as opposed to just this one) useful or silly? Johnathan M Davis replied: As soon as you have a const or immutable member i

Re: join of range of ranges?

2013-09-22 Thread David Nadlinger
On Sunday, 22 September 2013 at 14:26:14 UTC, bearophile wrote: In some cases I'd like to join a range of ranges in a single array/string (I know here the inner map could be replaced by something better, this code is just an example): std.algorithm.joiner, or am I missing something? David

Re: Regression or bugfix?

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 13:50:00 UTC, simendsjo wrote: In 2.063.2, (T!int).stringof == "T!(int)". In current head, it's "T!int". Even (T!(int)).stringof == "T!int". So is this a regression bug or a bugfix? Added a ticket so it doesn't get lost: http://d.puremagic.com/issues/show_bug.

join of range of ranges?

2013-09-22 Thread bearophile
In some cases I'd like to join a range of ranges in a single array/string (I know here the inner map could be replaced by something better, this code is just an example): import std.algorithm: map; import std.array: join, array; void main() { auto r1 = [1, 2] .map!(x => [1, 2

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 13:36:48 UTC, simendsjo wrote: On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of

Regression or bugfix?

2013-09-22 Thread simendsjo
In 2.063.2, (T!int).stringof == "T!(int)". In current head, it's "T!int". Even (T!(int)).stringof == "T!int". So is this a regression bug or a bugfix?

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of code that gives that error? Bye, bearophile dustmite for the

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
On Sunday, 22 September 2013 at 12:26:03 UTC, bearophile wrote: simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of code that gives that error? Bye, bearophile Nope. I cannot ge

Re: Cannot use locat x as parameter to non-global template y

2013-09-22 Thread bearophile
simendsjo: God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out... Can you show a small example of code that gives that error? Bye, bearophile

Cannot use locat x as parameter to non-global template y

2013-09-22 Thread simendsjo
God, I hate these errors. Tried updating dmd head, and these started popping up. Now I have to move all templates out...

Re: core.sys.posix.unistd link error

2013-09-22 Thread Ruslan Mullakhmetov
I found where the problem is. I used a system call (external C function) in class ctor. then I declared global variable of this class and INITIALZIED that variable inplace. If i move initalization in module static this() everything compiles. the code is: incorrect version: http://dpaste.co

Re: core.sys.posix.unistd link error

2013-09-22 Thread Ruslan Mullakhmetov
Didn't catch. How can I use it at runtime? I can not link to actually C function? On Saturday, 21 September 2013 at 19:40:48 UTC, Jonathan M Davis wrote: On Saturday, September 21, 2013 20:30:00 Ruslan Mullakhmetov wrote: i use pipe() syscall from my program. when i compile it I got the fo