Re: User defined attributes use

2013-09-23 Thread simendsjo
On Monday, 23 September 2013 at 07:47:32 UTC, Jacob Carlborg wrote: On 2013-09-20 16:12, simendsjo wrote: You could of course fix this in a library too. enum AttributeUsage { struct_ = 1 << 0, class_ = 1 << 1, //etc } struct attribute { AttributeUsage usage; } Then the library could gi

Re: User defined attributes use

2013-09-23 Thread Jacob Carlborg
On 2013-09-20 16:12, simendsjo wrote: You could of course fix this in a library too. enum AttributeUsage { struct_ = 1 << 0, class_ = 1 << 1, //etc } struct attribute { AttributeUsage usage; } Then the library could give a compile-time error if you tries to use it where it's not mean

Re: User defined attributes use

2013-09-20 Thread simendsjo
On Friday, 20 September 2013 at 07:57:43 UTC, Jacob Carlborg wrote: On 2013-09-20 08:59, ilya-stromberg wrote: Can I explicitly specify when I can use attribute? Something like this: @attribute("field") struct matches(string mustMatch) { } string wrongAttribute { } class Foo { @matches(

Re: User defined attributes use

2013-09-20 Thread Jacob Carlborg
On 2013-09-20 08:59, ilya-stromberg wrote: Can I explicitly specify when I can use attribute? Something like this: @attribute("field") struct matches(string mustMatch) { } string wrongAttribute { } class Foo { @matches("[0-9]+") string someNumber; //OK, it's a field } @matches("[0-

Re: User defined attributes use

2013-09-20 Thread ilya-stromberg
On Monday, 16 September 2013 at 07:36:13 UTC, simendsjo wrote: I don't have a full example without adding a lot of code, but this partial example might give you the gist of it. // This is the type that validates struct matches(string mustMatch) { alias re = ctRegex!(mustMatch); static

Re: User defined attributes use

2013-09-17 Thread Artur Skawina
On 09/17/13 00:53, H. S. Teoh wrote: > On Mon, Sep 16, 2013 at 10:59:10PM +0200, Artur Skawina wrote: >> On 09/16/13 22:38, Namespace wrote: [1] Obviously, not a practical short term option for the existing D2 language. That's probably clear from the context, and the questio

Re: User defined attributes use

2013-09-16 Thread Jacob Carlborg
On 2013-09-17 00:53, H. S. Teoh wrote: Hmm. I find D arrays just fine the way they are, actually. (In fact, I rather *liked* the way D arrays worked as compared with, say, C/C++.) What's wrong with them? I guess one can complain about some of the built-in properties/functions, like sort. --

Re: User defined attributes use

2013-09-16 Thread Jacob Carlborg
On 2013-09-16 22:15, Namespace wrote: Then of course I have not said anything. The same thing I would suggest for scope. It exists as a library solution and is rewritten magical. I think the big difference here is that AA's are safe where "scope" is not. I agree with you, I like to use "scope

Re: User defined attributes use

2013-09-16 Thread Maxim Fomin
On Monday, 16 September 2013 at 19:21:47 UTC, H. S. Teoh wrote: On Mon, Sep 16, 2013 at 08:56:17PM +0200, Namespace wrote: [...] I hate this NotNull struct hack. It is the same crap as the current scope solution. BTW: I'm curious which built-in feature will be removed next, maybe AA? [...] Th

Re: User defined attributes use

2013-09-16 Thread H. S. Teoh
On Mon, Sep 16, 2013 at 10:59:10PM +0200, Artur Skawina wrote: > On 09/16/13 22:38, Namespace wrote: > >> [1] Obviously, not a practical short term option for the existing > >> D2 language. That's probably clear from the context, and the > >> question was meant to be rhetorical -- but it c

Re: User defined attributes use

2013-09-16 Thread Artur Skawina
On 09/16/13 22:52, H. S. Teoh wrote: > On Mon, Sep 16, 2013 at 10:38:58PM +0200, Namespace wrote: >>> D is not only about arrays. >> It's a big plus. ;) >> >> >>> [1] Obviously, not a practical short term option for the existing D2 >>> language. That's probably clear from the context, and the ques

Re: User defined attributes use

2013-09-16 Thread Artur Skawina
On 09/16/13 21:58, Namespace wrote: > On Monday, 16 September 2013 at 19:21:47 UTC, H. S. Teoh wrote: >> On Mon, Sep 16, 2013 at 08:56:17PM +0200, Namespace wrote: >> [...] >>> I hate this NotNull struct hack. It is the same crap as the current >>> scope solution. BTW: I'm curious which built-in fe

Re: User defined attributes use

2013-09-16 Thread H. S. Teoh
On Mon, Sep 16, 2013 at 10:38:58PM +0200, Namespace wrote: > >D is not only about arrays. > It's a big plus. ;) > > > >[1] Obviously, not a practical short term option for the existing D2 > >language. That's probably clear from the context, and the question > >was meant to be rhetorical -- but i

Re: User defined attributes use

2013-09-16 Thread Namespace
D is not only about arrays. It's a big plus. ;) [1] Obviously, not a practical short term option for the existing D2 language. That's probably clear from the context, and the question was meant to be rhetorical -- but it could actually be done and would make sense; it's just not

Re: User defined attributes use

2013-09-16 Thread Artur Skawina
On 09/16/13 22:38, Namespace wrote: >> [1] Obviously, not a practical short term option for the existing D2 >> language. >> That's probably clear from the context, and the question was meant to be >> rhetorical -- but it could actually be done and would make sense; it's >> just >> not

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 21:11:00 UTC, Artur Skawina wrote: On 09/16/13 22:52, H. S. Teoh wrote: On Mon, Sep 16, 2013 at 10:38:58PM +0200, Namespace wrote: D is not only about arrays. It's a big plus. ;) [1] Obviously, not a practical short term option for the existing D2 language.

Re: User defined attributes use

2013-09-16 Thread ilya-stromberg
On Monday, 16 September 2013 at 20:16:45 UTC, Namespace wrote: And maybe also for delete: we need something to delete the memory manually. And we need built-in memory allocators, not only GC.

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 20:09:53 UTC, Adam D. Ruppe wrote: On Monday, 16 September 2013 at 19:58:51 UTC, Namespace wrote: Why should anyone switch to D if it is nothing else as a new C++? It's worth pointing out that the library AAs proposed here would still have the same syntax as t

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 20:15:26 UTC, Namespace wrote: On Monday, 16 September 2013 at 20:09:53 UTC, Adam D. Ruppe wrote: On Monday, 16 September 2013 at 19:58:51 UTC, Namespace wrote: Why should anyone switch to D if it is nothing else as a new C++? It's worth pointing out that the

Re: User defined attributes use

2013-09-16 Thread Adam D. Ruppe
On Monday, 16 September 2013 at 19:58:51 UTC, Namespace wrote: Why should anyone switch to D if it is nothing else as a new C++? It's worth pointing out that the library AAs proposed here would still have the same syntax as the built-in ones now. int[string] a; would just be magically rewr

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 19:21:47 UTC, H. S. Teoh wrote: On Mon, Sep 16, 2013 at 08:56:17PM +0200, Namespace wrote: [...] I hate this NotNull struct hack. It is the same crap as the current scope solution. BTW: I'm curious which built-in feature will be removed next, maybe AA? [...] Th

Re: User defined attributes use

2013-09-16 Thread ilya-stromberg
On Monday, 16 September 2013 at 19:28:22 UTC, Andrei Alexandrescu wrote: On 9/16/13 11:56 AM, Namespace wrote: And I agree absolute, to disable default CTor's by struct's was a huge mistake. But D is full of those. ;) They are not disabled. It seems many people are having trouble with gettin

Re: User defined attributes use

2013-09-16 Thread H. S. Teoh
On Mon, Sep 16, 2013 at 12:28:21PM -0700, Andrei Alexandrescu wrote: > On 9/16/13 11:56 AM, Namespace wrote: > >I hate this NotNull struct hack. It is the same crap as the current > >scope solution. > > Scoped variables in the language were a lot worse. One thing I'd *really* like to have is prop

Re: User defined attributes use

2013-09-16 Thread Andrei Alexandrescu
On 9/16/13 11:56 AM, Namespace wrote: I hate this NotNull struct hack. It is the same crap as the current scope solution. Scoped variables in the language were a lot worse. BTW: I'm curious which built-in feature will be removed next, maybe AA? If we're diligent and lucky, hopefully. An a

Re: User defined attributes use

2013-09-16 Thread Namespace
Long time not heard from each other. ;) On Monday, 16 September 2013 at 19:28:22 UTC, Andrei Alexandrescu wrote: On 9/16/13 11:56 AM, Namespace wrote: I hate this NotNull struct hack. It is the same crap as the current scope solution. Scoped variables in the language were a lot worse. Why?

Re: User defined attributes use

2013-09-16 Thread H. S. Teoh
On Mon, Sep 16, 2013 at 08:56:17PM +0200, Namespace wrote: [...] > I hate this NotNull struct hack. It is the same crap as the current > scope solution. BTW: I'm curious which built-in feature will be > removed next, maybe AA? [...] That wouldn't be a bad idea, actually. The current AA implementat

Re: User defined attributes use

2013-09-16 Thread simendsjo
On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@nonNull C c) { ... }; C c; fun(c); //compilation error since

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 18:44:25 UTC, ilya-stromberg wrote: On Monday, 16 September 2013 at 17:50:16 UTC, Maxim Fomin wrote: Ideally structs should have default constructors (hello to those who miss them - problem #2) which could initialize class instance. Do you know why D structs do

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 17:50:16 UTC, Maxim Fomin wrote: On Monday, 16 September 2013 at 16:50:43 UTC, Namespace wrote: On Monday, 16 September 2013 at 15:47:36 UTC, ilya-stromberg wrote: On Monday, 16 September 2013 at 15:12:05 UTC, Maxim Fomin wrote: On Monday, 16 September 2013 at 10

Re: User defined attributes use

2013-09-16 Thread ilya-stromberg
On Monday, 16 September 2013 at 17:50:16 UTC, Maxim Fomin wrote: Ideally structs should have default constructors (hello to those who miss them - problem #2) which could initialize class instance. Do you know why D structs don't have default constructors? I really miss.

Re: User defined attributes use

2013-09-16 Thread Maxim Fomin
On Monday, 16 September 2013 at 16:50:43 UTC, Namespace wrote: On Monday, 16 September 2013 at 15:47:36 UTC, ilya-stromberg wrote: On Monday, 16 September 2013 at 15:12:05 UTC, Maxim Fomin wrote: On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank y

Re: User defined attributes use

2013-09-16 Thread Namespace
On Monday, 16 September 2013 at 15:47:36 UTC, ilya-stromberg wrote: On Monday, 16 September 2013 at 15:12:05 UTC, Maxim Fomin wrote: On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler wou

Re: User defined attributes use

2013-09-16 Thread ilya-stromberg
On Monday, 16 September 2013 at 15:12:05 UTC, Maxim Fomin wrote: On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@

Re: User defined attributes use

2013-09-16 Thread Maxim Fomin
On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@nonNull C c) { ... }; C c; fun(c); //compilation error since

Re: User defined attributes use

2013-09-16 Thread matovitch
On Monday, 16 September 2013 at 10:36:16 UTC, Bienlein wrote: On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@non

Re: User defined attributes use

2013-09-16 Thread Bienlein
On Monday, 16 September 2013 at 10:29:12 UTC, matovitch wrote: All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@nonNull C c) { ... }; C c; fun(c); //compilation error since

Re: User defined attributes use

2013-09-16 Thread matovitch
All your examples are great, thank you ! Is there a way to omit validate such that the compiler would call it implicitly ? For example : class C { ... } void fun(@nonNull C c) { ... }; C c; fun(c); //compilation error since C is null

Re: User defined attributes use

2013-09-16 Thread simendsjo
On Monday, 16 September 2013 at 06:47:40 UTC, ilya-stromberg wrote: On Sunday, 15 September 2013 at 18:31:40 UTC, simendsjo wrote: On Sunday, 15 September 2013 at 17:34:06 UTC, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses. Ok

Re: User defined attributes use

2013-09-15 Thread ilya-stromberg
On Sunday, 15 September 2013 at 18:31:40 UTC, simendsjo wrote: On Sunday, 15 September 2013 at 17:34:06 UTC, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses. Ok, it'a a template expression you can link to a declaration, but what

Re: User defined attributes use

2013-09-15 Thread simendsjo
On Sunday, 15 September 2013 at 17:34:06 UTC, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses. Ok, it'a a template expression you can link to a declaration, but what are they useful for ? (not sure about the syntax ;-)) Can yo

Re: User defined attributes use

2013-09-15 Thread Jacob Carlborg
On 2013-09-15 19:34, matovitch wrote: Hi everyone, I read the documentation about user defined attributes, but I don't see their uses. I'm using it in my serialization library: struct Foo { int a; @nonSerialized int b; } Indicates "b" will not be serialized. struct Bar { int a;