Re: imports in functions

2011-06-20 Thread Andrej Mitrovic
Aaaargh, I've used function imports, completely disregarding that they're not present in 2.053 and now I can't deploy code to github because people won't be able to compile it. Ahh the joys.. Well I'm glad I caught this now before embarrassing myself.

Re: imports in functions

2011-06-20 Thread Andrej Mitrovic
On 6/21/11, Nick Sabalausky wrote: > UFCS barely works at all in D2. Another example: Couple that with the classically buggy 'with' statement and you've got yourself a party! \o/

Re: imports in functions

2011-06-20 Thread Nick Sabalausky
"Andrej Mitrovic" wrote in message news:mailman.1030.1308543325.14074.digitalmar...@puremagic.com... >I think I've just found the first bug: > > module test; > void main() > { > } > > void foo() > { >import std.utf; >"bla".toUTF16z; > } > > Error: undefined identifier module test.toUTF16

Re: imports in functions

2011-06-20 Thread Ary Manzana
On 6/20/11 3:04 PM, Jacob Carlborg wrote: On 2011-06-20 05:18, Ary Manzana wrote: On 6/19/11 5:20 AM, Andrej Mitrovic wrote: This is such a great debugging tool. I mean ddbg is great on its own. But being able to quickly import std.stdio and do a few debug writes in some library function is fan

Re: imports in functions

2011-06-20 Thread Jacob Carlborg
On 2011-06-20 05:18, Ary Manzana wrote: On 6/19/11 5:20 AM, Andrej Mitrovic wrote: This is such a great debugging tool. I mean ddbg is great on its own. But being able to quickly import std.stdio and do a few debug writes in some library function is fantastic. print-debugging is so common... i

Re: imports in functions

2011-06-19 Thread Andrej Mitrovic
I think I've just found the first bug: module test; void main() { } void foo() { import std.utf; "bla".toUTF16z; } Error: undefined identifier module test.toUTF16z UFCS doesn't work with function imports. This is a bug, right?

Re: imports in functions

2011-06-19 Thread Ary Manzana
On 6/19/11 5:20 AM, Andrej Mitrovic wrote: This is such a great debugging tool. I mean ddbg is great on its own. But being able to quickly import std.stdio and do a few debug writes in some library function is fantastic. print-debugging is so common... in Ruby you always have "puts" available,

Re: imports in functions

2011-06-18 Thread Andrej Mitrovic
This is such a great debugging tool. I mean ddbg is great on its own. But being able to quickly import std.stdio and do a few debug writes in some library function is fantastic.

Re: imports in functions

2011-06-17 Thread Jacob Carlborg
On 2011-06-12 23:15, Walter Bright wrote: Nobody seems to have noticed yet, but yesterday I removed the restriction preventing import declarations from being used in functions. These now work: void test1() { import std.c.stdio; printf("hello world\n"); } void test2() { static import std.c.stdio

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
Well it seems to work fine. :)

Re: imports in functions

2011-06-13 Thread Brad Roberts
On 6/13/2011 8:48 PM, Andrej Mitrovic wrote: > I'm guessing this is what you're after: > > http://codepad.org/TCtG68Fw > http://codepad.org/65GBDjPS > > rdmd main.d > shared ctor! > ctor! > foo.test > dtor! > shared dtor! Actually, not what I was thinking. I was thinking something like this: f

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
Should DLLs even have module ctors/dtors? I think this is what DLLMain's DLL_PROCESS_ATTACH, DLL_THREAD_ATTACH and their detach counterparts are for.

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
I'm guessing this is what you're after: http://codepad.org/TCtG68Fw http://codepad.org/65GBDjPS rdmd main.d shared ctor! ctor! foo.test dtor! shared dtor!

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
And they do run, I've tested it in a non-DLL example.

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
When I add module ctors/dtors, I get the ModuleInfoZ shenanigans again.

Re: imports in functions

2011-06-13 Thread Brad Roberts
On 6/13/2011 8:28 PM, Andrej Mitrovic wrote: > Walter, it looks like this addition inadvertently fixes the issue of > DLLs not linkable due to Phobos imports. > > I've had this DLL (alongside with dllmodule.d which had initialization > calls inside DLLMain): > module EdrLib; > > import std.utf; >

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
Walter, it looks like this addition inadvertently fixes the issue of DLLs not linkable due to Phobos imports. I've had this DLL (alongside with dllmodule.d which had initialization calls inside DLLMain): module EdrLib; import std.utf; pragma(lib, "gdi32.lib"); pragma(lib, "comdlg32.lib"); import

Re: imports in functions

2011-06-13 Thread KennyTM~
On Jun 14, 11 03:55, Andrej Mitrovic wrote: Btw, it's disappointing that I can't call split with a separator at compile-time: enum result = split("bla, bla"); // ok enum result = split("bla, bla", ","); // nope That's due to (at least) http://d.puremagic.com/issues/show_bug.cgi?id=4047.

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
Btw, it's disappointing that I can't call split with a separator at compile-time: enum result = split("bla, bla"); // ok enum result = split("bla, bla", ","); // nope

Re: imports in functions

2011-06-13 Thread Andrej Mitrovic
I'm having some fun with this. import std.array; void main() { with (namespace!("std.stdio std.algorithm std.range")) { auto squares = map!("a * a")([2, 4, 6]); writeln(squares); } } template namespace(string x) { mixin(namespaceImpl(x)); } string namespaceImpl(s

Re: imports in functions

2011-06-13 Thread Robert Clipsham
On 12/06/2011 22:15, Walter Bright wrote: Nobody seems to have noticed yet, but yesterday I removed the restriction preventing import declarations from being used in functions. These now work: void test1() { import std.c.stdio; printf("hello world\n"); } void test2() { static import std.c.stdio

Re: imports in functions

2011-06-12 Thread Andrei Alexandrescu
On 6/12/11 5:08 PM, Andrej Mitrovic wrote: This seems like a way to simulate namespaces in C++, right? I wouldn't know, but it looks similar to that 'using foo' trick. I hope not :o). C++ namespaces are quite lacking. Andrei

Re: imports in functions

2011-06-12 Thread Andrej Mitrovic
On 6/13/11, Jonathan M Davis wrote: < snip> So much for my blurry recollection of C++ features. :-)

Re: imports in functions

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 15:08, Andrej Mitrovic wrote: > This seems like a way to simulate namespaces in C++, right? I wouldn't > know, but it looks similar to that 'using foo' trick. C++ namespaces are completely different. Everything in a namespace has to be referenced by its namespace explicitly unless y

Re: imports in functions

2011-06-12 Thread Dmitry Olshansky
On 13.06.2011 1:15, Walter Bright wrote: Nobody seems to have noticed yet, but yesterday I removed the restriction preventing import declarations from being used in functions. These now work: void test1() { import std.c.stdio; printf("hello world\n"); } void test2() { static impor

Re: imports in functions

2011-06-12 Thread Lars T. Kyllingstad
On Sun, 12 Jun 2011 14:15:27 -0700, Walter Bright wrote: > Nobody seems to have noticed yet, but yesterday I removed the > restriction preventing import declarations from being used in functions. > These now work: > > void test1() > { > import std.c.stdio; > printf("hello world\n"); > }

Re: imports in functions

2011-06-12 Thread Andrej Mitrovic
This seems like a way to simulate namespaces in C++, right? I wouldn't know, but it looks similar to that 'using foo' trick.

Re: imports in functions

2011-06-12 Thread Andrei Alexandrescu
On 06/12/2011 04:33 PM, Adam D. Ruppe wrote: This is awesome! Another benefit here is code running programs are simplified. For "D script" kind of things, a technique I use is to simply wrap some code inside a main function. Almost every feature worked there - nested functions, structs, classes,

Re: imports in functions

2011-06-12 Thread Adam D. Ruppe
This is awesome! Another benefit here is code running programs are simplified. For "D script" kind of things, a technique I use is to simply wrap some code inside a main function. Almost every feature worked there - nested functions, structs, classes, etc. Now imports do too! Yay!

Re: imports in functions

2011-06-12 Thread Andrei Alexandrescu
On 06/12/2011 04:15 PM, Walter Bright wrote: Nobody seems to have noticed yet, but yesterday I removed the restriction preventing import declarations from being used in functions. These now work: void test1() { import std.c.stdio; printf("hello world\n"); } void test2() { static import std.c.st

imports in functions

2011-06-12 Thread Walter Bright
Nobody seems to have noticed yet, but yesterday I removed the restriction preventing import declarations from being used in functions. These now work: void test1() { import std.c.stdio; printf("hello world\n"); } void test2() { static import std.c.stdio; std.c.stdio.printf("hell