Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread bearophile
Trass3r: > Nobody got an answer? My opinion: - complex types will be removed. And as far as I know complex number literals too will be removed from D (this is less nice). - I am not sure regarding C-style struct initializations. They are useful to save some typing if you have to for example to p

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Andrei Alexandrescu
On 05/31/2010 02:14 PM, bearophile wrote: Trass3r: Nobody got an answer? My opinion: - complex types will be removed. And as far as I know complex number literals too will be removed from D (this is less nice). - I am not sure regarding C-style struct initializations. They are useful to save

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread bearophile
Andrei Alexandrescu: > typedef is gone. *mewls* I have shown here some examples of typedef usage, and I'll keep posting few more in future. I'd like to pull it back from the grave and keep it :-) Bye, bearophile

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Adam Ruppe
Doesn't struct T { R _payload; } accomplish the same thing as typedef R T; in the majority of useful cases? I use typedef void* Some_C_Type; a lot, and rather like it for a handful of other things, but I'm pretty sure the struct accomplishes the same thing in those cases. As a template in the

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Andrei Alexandrescu
On 05/31/2010 03:54 PM, bearophile wrote: Andrei Alexandrescu: typedef is gone. *mewls* I have shown here some examples of typedef usage, and I'll keep posting few more in future. I'd like to pull it back from the grave and keep it :-) It's wasted time. typedef is gone. Andrei

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Andrei Alexandrescu
On 05/31/2010 04:11 PM, Adam Ruppe wrote: Doesn't struct T { R _payload; } accomplish the same thing as typedef R T; in the majority of useful cases? Exactly. And with alias this and other mechanisms, you can define several well-defined typedef incarnations that achieve what you want to e

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Lionello Lunesu
On 1-6-2010 5:38, Andrei Alexandrescu wrote: > On 05/31/2010 03:54 PM, bearophile wrote: >> Andrei Alexandrescu: >>> typedef is gone. >> >> *mewls* I have shown here some examples of typedef usage, and I'll >> keep posting few more in future. I'd like to pull it back from the >> grave and keep it :

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Ellery Newcomer
On 05/31/2010 03:54 PM, bearophile wrote: Andrei Alexandrescu: typedef is gone. *mewls* I have shown here some examples of typedef usage, and I'll keep posting few more in future. I'd like to pull it back from the grave and keep it :-) Bye, bearophile user specified T.init?

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Lionello Lunesu
On 1-6-2010 6:25, Ellery Newcomer wrote: > user specified T.init? I love(d) that feature!

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Justin Spahr-Summers
On Tue, 01 Jun 2010 06:05:50 +0800, Lionello Lunesu wrote: > > On 1-6-2010 5:38, Andrei Alexandrescu wrote: > > On 05/31/2010 03:54 PM, bearophile wrote: > >> Andrei Alexandrescu: > >>> typedef is gone. > >> > >> *mewls* I have shown here some examples of typedef usage, and I'll > >> keep postin

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Trass3r
So what would be the way to translate those Windows headers? Create a unique struct for each old typedef? With alias this, and a ctor? Well, if that's the way to do it now, why not make typedef a shortcut for exactly that!? Yeah there must be some short and clean way to define it. IIRC typede

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Simen kjaeraas
Lionello Lunesu wrote: I also miss typedef. I thought D had a great opportunity to fix it. Take something like the Windows headers. It mostly consists of typedefs for handles and whatnot. Without typedef you'd have to use alias and type safety is out of the windows. So what would be the way t

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Leandro Lucarella
Justin Spahr-Summers, el 31 de mayo a las 16:41 me escribiste: > On Tue, 01 Jun 2010 06:05:50 +0800, Lionello Lunesu > wrote: > > > > On 1-6-2010 5:38, Andrei Alexandrescu wrote: > > > On 05/31/2010 03:54 PM, bearophile wrote: > > >> Andrei Alexandrescu: > > >>> typedef is gone. > > >> > > >> *m

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Andrei Alexandrescu
On 05/31/2010 10:07 PM, Simen kjaeraas wrote: Lionello Lunesu wrote: I also miss typedef. I thought D had a great opportunity to fix it. Take something like the Windows headers. It mostly consists of typedefs for handles and whatnot. Without typedef you'd have to use alias and type safety is

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Trass3r
struct Typedef( T ) { T payload; alias payload this; } alias Typedef!int myInt; There you go. The question is if this still works flawlessly for complicated examples.

Re: need clarification: will typedef, C struct initialization, etc.

2010-05-31 Thread Justin Spahr-Summers
On Mon, 31 May 2010 23:31:18 -0300, Leandro Lucarella wrote: > > Justin Spahr-Summers, el 31 de mayo a las 16:41 me escribiste: > > On Tue, 01 Jun 2010 06:05:50 +0800, Lionello Lunesu > > wrote: > > > > > > On 1-6-2010 5:38, Andrei Alexandrescu wrote: > > > > On 05/31/2010 03:54 PM, bearophil

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-01 Thread Lars T. Kyllingstad
On Tue, 01 Jun 2010 05:07:21 +0200, Simen kjaeraas wrote: > Lionello Lunesu wrote: > >> I also miss typedef. I thought D had a great opportunity to fix it. >> >> Take something like the Windows headers. It mostly consists of typedefs >> for handles and whatnot. Without typedef you'd have to use

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-01 Thread Kagamin
Leandro Lucarella Wrote: > I think he talks about this difference: > > alias int a1; > alias int a2; > typedef int t1; > typedef int t2; > > void fa(a2 a) {} > void ft(t2 t) {} > > void main() { > a1 a = 5; > fa(a); // <--- compiles fine > t1 t = 10; > ft(t); // <--- err

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-01 Thread Lionello Lunesu
On 1-6-2010 12:05, Justin Spahr-Summers wrote: > On Mon, 31 May 2010 23:31:18 -0300, Leandro Lucarella > wrote: >> >> Justin Spahr-Summers, el 31 de mayo a las 16:41 me escribiste: >>> On Tue, 01 Jun 2010 06:05:50 +0800, Lionello Lunesu >>> wrote: On 1-6-2010 5:38, Andrei Alexandrescu

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-01 Thread Lionello Lunesu
On 1-6-2010 18:04, Kagamin wrote: > Leandro Lucarella Wrote: > >> I think he talks about this difference: >> >> alias int a1; >> alias int a2; >> typedef int t1; >> typedef int t2; >> >> void fa(a2 a) {} >> void ft(t2 t) {} >> >> void main() { >> a1 a = 5; >> fa(a); // <--- compiles fine

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-01 Thread Lionello Lunesu
On 1-6-2010 11:37, Andrei Alexandrescu wrote: > On 05/31/2010 10:07 PM, Simen kjaeraas wrote: >> Lionello Lunesu wrote: >> >>> I also miss typedef. I thought D had a great opportunity to fix it. >>> >>> Take something like the Windows headers. It mostly consists of typedefs >>> for handles and wha

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread lurker
Lionello Lunesu Wrote: > On 1-6-2010 5:38, Andrei Alexandrescu wrote: > > On 05/31/2010 03:54 PM, bearophile wrote: > >> Andrei Alexandrescu: > >>> typedef is gone. > >> > >> *mewls* I have shown here some examples of typedef usage, and I'll > >> keep posting few more in future. I'd like to pull i

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Andrei Alexandrescu
On 06/02/2010 10:21 AM, lurker wrote: Lionello Lunesu Wrote: On 1-6-2010 5:38, Andrei Alexandrescu wrote: On 05/31/2010 03:54 PM, bearophile wrote: Andrei Alexandrescu: typedef is gone. *mewls* I have shown here some examples of typedef usage, and I'll keep posting few more in future. I'd

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Trass3r
I suggested eliminating typedef exactly because it was ill-defined and it was lacking rigorous semantics. Walter agreed to eliminating it exactly because he was unable to ground typedef's definition. Also, progress in other, better-defined areas of the language afford us to implement typede

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Simen kjaeraas
Andrei Alexandrescu wrote: struct Typedef( T ) { T payload; alias payload this; } alias Typedef!int myInt; There you go. Yah, perfect - that would be the subtype. I think we should work on adding a pseudo-supertype as well, and also on a completely independent type. Then we can add thes

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Adam Ruppe
On 6/2/10, Simen kjaeraas wrote: *snip* I haven't tried your code, but it looks similar to my own code, which had this problem: alias Typedef!Int Handle; alias Typedef!Int OtherHandle; void foo(Handle h) { } OtherHandle b; foo(b); // compiles, but shouldn't. Problem is that Handle and OtherHa

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Simen kjaeraas
On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe wrote: On 6/2/10, Simen kjaeraas wrote: *snip* I haven't tried your code, but it looks similar to my own code, which had this problem: alias Typedef!Int Handle; alias Typedef!Int OtherHandle; void foo(Handle h) { } OtherHandle b; foo(b); //

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread Adam Ruppe
How cool! I like that a lot.

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-02 Thread bearophile
Simen kjaeraas: > My code sidesteps that by including instantiation line and file, > making each instantiation unique (as long as you don't do > multiple typedefs on one line). Cute :-) We can also try to add/invent something similar to the CLisp gensym, that generates ever different symbols at c

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread Lars T. Kyllingstad
On Thu, 03 Jun 2010 00:02:03 +0200, Simen kjaeraas wrote: > On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe > wrote: > >> On 6/2/10, Simen kjaeraas wrote: *snip* >> >> I haven't tried your code, but it looks similar to my own code, which >> had this problem: >> >> alias Typedef!Int Handle; >> al

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread Lionello Lunesu
On 3-6-2010 14:58, Lars T. Kyllingstad wrote: > On Thu, 03 Jun 2010 00:02:03 +0200, Simen kjaeraas wrote: > >> On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe >> wrote: >> >>> On 6/2/10, Simen kjaeraas wrote: *snip* >>> >>> I haven't tried your code, but it looks similar to my own code, which >>>

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread bearophile
My suggestion is to just improve the built-in typedef, instead of trying to implement some hack in D. Lionello Lunesu: > Cool trick indeed, but why do we need a trick for something so basic!? For that a gensym is better than the date/file pair. But a gensym() despite being a simple thing might

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread Adam Ruppe
On 6/3/10, bearophile wrote: > My suggestion is to just improve the built-in typedef, instead of trying to > implement some hack in D. Do you consider ALL library solutions to be "hacks"? It sure seems that way at times. What we have here is individually useful language features able to complete

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread Andrei Alexandrescu
On 06/03/2010 12:17 PM, Adam Ruppe wrote: On 6/3/10, bearophile wrote: My suggestion is to just improve the built-in typedef, instead of trying to implement some hack in D. Do you consider ALL library solutions to be "hacks"? It sure seems that way at times. What we have here is individually

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread bearophile
Adam Ruppe: > Do you consider ALL library solutions to be "hacks"? It sure seems > that way at times. I have seen some situations where library solutions are not good enough yet: - std.bitmanip.bitfields is a marvel of programming, but it's trash any way: its code can't be maintained, modified, r

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread Adam Ruppe
On 6/3/10, bearophile wrote: > I have seen some situations where library solutions are not good enough yet: > - std.bitmanip.bitfields is a marvel of programming, but it's trash any way: > its code can't be maintained, modified, read. It's past the limit of > decency. When it comes to code access

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread bearophile
Adam Ruppe: > When it comes to code accessibility, the compiler is a black box. You > can't edit it, even in theory, without breaking the language. A > library's source might be ugly, but it is at least available for you > to play with while still writing valid D code. Code that can be mantained

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-03 Thread retard
Thu, 03 Jun 2010 15:08:08 -0400, Adam Ruppe wrote: > On 6/3/10, bearophile wrote: >> I have seen some situations where library solutions are not good enough >> yet: - std.bitmanip.bitfields is a marvel of programming, but it's >> trash any way: its code can't be maintained, modified, read. It's p

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-04 Thread Lionello Lunesu
On 4-6-2010 1:17, Adam Ruppe wrote: > > This strikes me as being a supremely elegant solution, not a hack. struct Typedef( T, T init = T.init, Type type = Type.Sub, string _f = __FILE__, int _l = __LINE__ ) { ... Yes, that's a hack. And it's great that we can do sub, super, independent and p

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-04 Thread Andrei Alexandrescu
On 06/04/2010 06:38 AM, Lionello Lunesu wrote: On 4-6-2010 1:17, Adam Ruppe wrote: This strikes me as being a supremely elegant solution, not a hack. struct Typedef( T, T init = T.init, Type type = Type.Sub, string _f = __FILE__, int _l = __LINE__ ) { ... Yes, that's a hack. And it's gr

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread Lutger
Andrei Alexandrescu wrote: > On 05/31/2010 02:14 PM, bearophile wrote: >> Trass3r: >>> Nobody got an answer? >> >> My opinion: >> - complex types will be removed. And as far as I know complex number >> literals too will be removed from D (this is less nice). - I am not sure >> regarding C-style st

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread Andrei Alexandrescu
On 06/06/2010 10:23 AM, Lutger wrote: Andrei Alexandrescu wrote: On 05/31/2010 02:14 PM, bearophile wrote: Trass3r: Nobody got an answer? My opinion: - complex types will be removed. And as far as I know complex number literals too will be removed from D (this is less nice). - I am not sure

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread Ellery Newcomer
On 06/06/2010 10:40 AM, Andrei Alexandrescu wrote: On 06/06/2010 10:23 AM, Lutger wrote: Andrei Alexandrescu wrote: On 05/31/2010 02:14 PM, bearophile wrote: Trass3r: Nobody got an answer? My opinion: - complex types will be removed. And as far as I know complex number literals too will be

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread bearophile
Ellery Newcomer: > Ooo Ooo Ooo Can we get rid of them? Pretty pretty please? Why are you so eager to remove them? (They are not essential, D has plenty of other ways (maybe even too many) to instantiate a struct. But I have appreciated C-style struct initializers in D because they give a more c

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread Ellery Newcomer
On 06/06/2010 10:47 AM, bearophile wrote: Ellery Newcomer: Ooo Ooo Ooo Can we get rid of them? Pretty pretty please? Why are you so eager to remove them? (They are not essential, D has plenty of other ways (maybe even too many) to instantiate a struct. But I have appreciated C-style struct i

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread bearophile
Ellery Newcomer: > because they're difficult to disambiguate from function literals (at > least dmd doesn't do it correctly) > > because they entail a lot of lookahead (I don't know, but I suspect they > are the cause for most of the slowness in my parser) I see. Thank you for your recent patch

Re: need clarification: will typedef, C struct initialization, etc.

2010-06-06 Thread Ellery Newcomer
On 06/06/2010 11:57 AM, bearophile wrote I see. Thank you for your recent patches. I think you can fix even bug 4283 too :-) Bye, bearophile I vaguely remember going to great length to ensure my parser did the exact same thing as what dmd does here

need clarification: will typedef, C struct initialization, etc. go or not?

2010-05-17 Thread Trass3r
There have been lots of discussions about removing language parts. I don't want this thread to become yet another one. I just want to know if (and when) these features will be removed or not. Especially typedef, which I found quite useful lately. C-style struct initialization and complex types hav

Re: need clarification: will typedef, C struct initialization, etc. go or not?

2010-05-31 Thread Trass3r
I just want to know if (and when) these features will be removed or not. Especially typedef, which I found quite useful lately. C-style struct initialization and complex types have also been discussed but are still in. Nobody got an answer?

Re: need clarification: will typedef, C struct initialization, etc. go or not?

2010-05-17 Thread Kagamin
And this should go into docs.

Re: need clarification: will typedef, C struct initialization, etc. go or not?

2010-05-18 Thread Trass3r
And this should go into docs. True.