Re: how to get enclosing function as symbol ? (eg: __function__.stringof ==__FUNCTION__)

2013-08-17 Thread Kapps
On Sunday, 18 August 2013 at 01:52:50 UTC, Timothee Cour wrote: Is there any way to get the enclosing function as symbol ? I'd like something like that: alternative names would be: __function__ __context__ auto fun(alias caller=__function__)(){ //caller represents fun1!double return Re

Re: how to get enclosing function as symbol ? (eg: __function__.stringof ==__FUNCTION__)

2013-08-17 Thread JS
On Sunday, 18 August 2013 at 01:52:50 UTC, Timothee Cour wrote: Is there any way to get the enclosing function as symbol ? I'd like something like that: alternative names would be: __function__ __context__ auto fun(alias caller=__function__)(){ //caller represents fun1!double return Re

Re: more enum and pragma troubles

2013-08-17 Thread JS
On Sunday, 18 August 2013 at 00:17:22 UTC, captaindet wrote: On 2013-08-17 14:36, Jesse Phillips wrote: Third you've declared a variable, bar, which will store your enumerated value, 4. Variables are not compile time, even if the value stored came from a compile time known value. yep, it com

how to get enclosing function as symbol ? (eg: __function__.stringof ==__FUNCTION__)

2013-08-17 Thread Timothee Cour
Is there any way to get the enclosing function as symbol ? I'd like something like that: alternative names would be: __function__ __context__ auto fun(alias caller=__function__)(){ //caller represents fun1!double return ReturnType!caller.init; } T fun1(T)(T x){ assert(__function__.str

Re: scoped imports

2013-08-17 Thread Timothee Cour
that's not DRY: in my use case, a group of functions use certain imports, it would be annoying and not DRY to do that. What I suggest (allowing {} grouping at module scope) seems simple and intuitive; any reason it can't be done? On Sat, Aug 17, 2013 at 6:16 PM, Joseph Rushton Wakeling < joseph.w

Re: scoped imports

2013-08-17 Thread Joseph Rushton Wakeling
On Saturday, 17 August 2013 at 22:30:14 UTC, Timothee Cour wrote: Is there a way to achieve this: module foo; { import bar; void fun1(){bar.barfun();} void fun2(bar.BarType a){} } // now bar is not in scope anymore. void fun3(){} This would reduce name clashes conflicts, ease refact

Re: scoped imports

2013-08-17 Thread bearophile
H. S. Teoh: Unfortunately, it's not within my control. It's the mailing list to NNTP gateway that has a bug where message IDs are sometimes rewritten when they're not supposed to be. I suggest you should pester the listmaster instead, that way, we'll get a solution that works for everybody, n

Re: scoped imports

2013-08-17 Thread H. S. Teoh
On Sun, Aug 18, 2013 at 01:24:12AM +0200, bearophile wrote: > H. S. Teoh: > > Most of your answer posts break threads. I suggest you to try to > find ways to avoid that. [...] Unfortunately, it's not within my control. It's the mailing list to NNTP gateway that has a bug where message IDs are som

Re: more enum and pragma troubles

2013-08-17 Thread captaindet
On 2013-08-17 14:36, Jesse Phillips wrote: Third you've declared a variable, bar, which will store your enumerated value, 4. Variables are not compile time, even if the value stored came from a compile time known value. yep, it completely escaped me that these are 'normal' variables. and i have

Re: scoped imports

2013-08-17 Thread Timothee Cour
On Sat, Aug 17, 2013 at 3:36 PM, H. S. Teoh wrote: > On Sat, Aug 17, 2013 at 03:29:56PM -0700, Timothee Cour wrote: > [...] > > Related question: > > > > Why isn't the following allowed: > > > > void fun(){ > > // code without version=A > > version=A; > > // code with version=A > > vesio

Re: how to get (absolute) file path from ModuleInfo? how to get include search path?

2013-08-17 Thread Timothee Cour
Additionally, is there a way to get: * the absolute path of __FILE__ at the time the file was compiled (the compiler knows it) * the current directory in which the compiler compiled that file On Sat, Aug 17, 2013 at 1:26 PM, Timothee Cour wrote: > I'd like to redefine 'void _d_assertm(ModuleInf

Re: scoped imports

2013-08-17 Thread Timothee Cour
thanks. That's a bit clunky though, so it's unlikely to be used. Not sure what it would take to make the grammar allow it. On Sat, Aug 17, 2013 at 4:23 PM, bearophile wrote: > Timothee Cour: > > > Is there a way to achieve this: >> >> >> module foo; >> >> { >> import bar; >> void fun1(){ba

Re: scoped imports

2013-08-17 Thread Timothee Cour
On Sat, Aug 17, 2013 at 4:24 PM, bearophile wrote: > H. S. Teoh: > > Most of your answer posts break threads. I suggest you to try to find ways > to avoid that. > This issue keeps reappearing and people keep complaining; it's not his fault, the problem is with the forum.dlang.org and that should

Re: scoped imports

2013-08-17 Thread bearophile
H. S. Teoh: Most of your answer posts break threads. I suggest you to try to find ways to avoid that. Bye, bearophile

Re: scoped imports

2013-08-17 Thread bearophile
Timothee Cour: Is there a way to achieve this: module foo; { import bar; void fun1(){bar.barfun();} void fun2(bar.BarType a){} } // now bar is not in scope anymore. Using a struct as namespace: struct Foo { import std.stdio; static void bar(int x) { x.writeln; } } alias bar =

Re: scoped imports

2013-08-17 Thread H. S. Teoh
On Sat, Aug 17, 2013 at 03:29:56PM -0700, Timothee Cour wrote: [...] > Related question: > > Why isn't the following allowed: > > void fun(){ > // code without version=A > version=A; > // code with version=A > vesion(none): > //code versioned out > } > > I understand the grammar does

scoped imports

2013-08-17 Thread Timothee Cour
Is there a way to achieve this: module foo; { import bar; void fun1(){bar.barfun();} void fun2(bar.BarType a){} } // now bar is not in scope anymore. void fun3(){} This would reduce name clashes conflicts, ease refactorings and in general make code a bit cleaner. Related question: W

Re: Smart way to convert a C string to a D string

2013-08-17 Thread andrea9940
Excellent discovery !

how to get (absolute) file path from ModuleInfo? how to get include search path?

2013-08-17 Thread Timothee Cour
I'd like to redefine 'void _d_assertm(ModuleInfo* m, uint line){...}' to print more informative message with full path to module; right now m.name just shows module name. Is the only way to manually search through include paths until it is found ? That seems silly because the compiler knows it alr

Re: more enum and pragma troubles

2013-08-17 Thread Jesse Phillips
On Saturday, 17 August 2013 at 05:22:53 UTC, captaindet wrote: import std.stdio; enum Test{ test2 = 2, test4 = 4 } Enumeration. enum foo = Test.test2; Manifest Const Test bar = Test.test4; Runtime variable. Enum is being abused. In the first case you are declaring an

Re: Large (>32 byte) concurrency messages

2013-08-17 Thread JR
On Saturday, 10 August 2013 at 15:12:39 UTC, Ali Çehreli wrote: On 08/10/2013 08:04 AM, JR wrote: This project made it very simple for me: https://github.com/carlor/dlang-workspace My belated thanks; this worked great.

Re: std.socket connect

2013-08-17 Thread Temtaime
Oh, i've found that that can be resolved by select(). Thanks.

std.socket connect

2013-08-17 Thread Temtaime
Hello guys! void connect(Address to); Establish a connection. If the socket is blocking, connect waits for the connection to be made. If the socket is nonblocking, connect returns immediately and the connection attempt is still in progress. How can i obtain information about progress when s

Re: why doesn't formattedRead take args by ref instead of by pointer?

2013-08-17 Thread Dmitry Olshansky
17-Aug-2013 12:53, Timothee Cour пишет: adding an overload would increases likelihood for bugs but could be possible. The same holds for getopt. Another question: the documentation for formattedRead is quite sparse, how does it explain the following behavior: string s="a1 a2 a3"; string a

Re: why doesn't formattedRead take args by ref instead of by pointer?

2013-08-17 Thread Timothee Cour
adding an overload would increases likelihood for bugs but could be possible. The same holds for getopt. Another question: the documentation for formattedRead is quite sparse, how does it explain the following behavior: string s="a1 a2 a3"; string a,b; uint n=formattedRead(s,"%s %s",&a,&b);

Re: more enum and pragma troubles

2013-08-17 Thread captaindet
On 2013-08-17 01:51, captaindet wrote: my understanding was that enums are all compile time entities that are just copied around. at compile time. a named enum type should make no difference. oh i see now, naming them is just creating a disguise for the base type. then they can become compile-

Re: more enum and pragma troubles

2013-08-17 Thread captaindet
On 2013-08-17 01:51, captaindet wrote: named enums become runtime objects -> named enums become runtime *only* objects