Re: Does the new alias syntax not support extern for function types?

2013-01-15 Thread Simen Kjaeraas
On 2013-04-15 13:01, Mike Parker wrote: On Monday, 14 January 2013 at 21:00:12 UTC, Simen Kjaeraas wrote: alias foo = extern(System) void function(); Gives me an error about expecting basic type, not extern. extern(System) alias void function() foo; But that's the old syntax, with which o

Re: Does the new alias syntax not support extern for function types?

2013-01-15 Thread Mike Parker
On Monday, 14 January 2013 at 21:00:12 UTC, Simen Kjaeraas wrote: alias foo = extern(System) void function(); Gives me an error about expecting basic type, not extern. extern(System) alias void function() foo;

Re: What is this strange alias syntax?

2011-05-23 Thread Stewart Gordon
On 22/05/2011 21:51, Timon Gehr wrote: I suspect what Andrej actually meant is to kill treating function signatures as types in this way. And possibly "enhancement request" rather than "bug". It is the opposite of an enhancement request. It means removing a feature that cannot be meaningfull

Re: What is this strange alias syntax?

2011-05-23 Thread Stewart Gordon
On 23/05/2011 07:43, David Nadlinger wrote: On 5/23/11 8:41 AM, Andrej Mitrovic wrote: What's wrong with using this: alias void function(int, int) funcAlias; It's a function pointer type, not a function type. How is that something wrong with it? I.e. what can you do with a function type

Re: What is this strange alias syntax?

2011-05-23 Thread Steven Schveighoffer
On Mon, 23 May 2011 14:06:31 -0400, Timon Gehr wrote: Steven Schveighoffer wrote: On Mon, 23 May 2011 10:50:11 -0400, Andrej Mitrovic wrote: Since &main can't be a template value argument, maybe he meant this use case: alias int func(); void foo(alias T)() { static assert(is(typeof

Re: What is this strange alias syntax?

2011-05-23 Thread Timon Gehr
Steven Schveighoffer wrote: > On Mon, 23 May 2011 10:50:11 -0400, Andrej Mitrovic > wrote: > >> Since &main can't be a template value argument, maybe he meant this use >> case: >> >> alias int func(); >> >> void foo(alias T)() >> { > static assert(is(typeof(&T) == int function())); // fixed

Re: What is this strange alias syntax?

2011-05-23 Thread Andrej Mitrovic
Nice.

Re: What is this strange alias syntax?

2011-05-23 Thread Steven Schveighoffer
On Mon, 23 May 2011 10:50:11 -0400, Andrej Mitrovic wrote: Since &main can't be a template value argument, maybe he meant this use case: alias int func(); void foo(alias T)() { static assert(is(typeof(&T) == int function())); // fixed } int main() { foo!main; return 0; }

Re: What is this strange alias syntax?

2011-05-23 Thread Andrej Mitrovic
Since &main can't be a template value argument, maybe he meant this use case: alias int func(); void foo(alias T)() { static assert(is(typeof(T) == func)); } int main() { foo!main; return 0; }

Re: What is this strange alias syntax?

2011-05-23 Thread Steven Schveighoffer
On Mon, 23 May 2011 09:59:01 -0400, Steven Schveighoffer wrote: On Mon, 23 May 2011 09:32:47 -0400, Timon Gehr wrote: Steven Schveighoffer wrote: it's akin to making: if(x); invalid. Yes, it's valid syntax, but it's almost certainly not what the user wanted. It's special cased for fail

Re: What is this strange alias syntax?

2011-05-23 Thread Steven Schveighoffer
On Mon, 23 May 2011 09:32:47 -0400, Timon Gehr wrote: Steven Schveighoffer wrote: it's akin to making: if(x); invalid. Yes, it's valid syntax, but it's almost certainly not what the user wanted. It's special cased for failure, to aid the developer in writing less buggy programs. This would

Re: What is this strange alias syntax?

2011-05-23 Thread Andrej Mitrovic
Well if there's no better way to do it and it's useful, we should do a feature request for a better syntax, no?

Re: What is this strange alias syntax?

2011-05-23 Thread Andrej Mitrovic
On 5/23/11, Timon Gehr wrote: > BTW: > > writeln(typeid(int function(int))); //int()* > > wtf? Yeah, typeid generally seems to be bad for these things. typeof.stringof to the rescue: writeln((int function(int)).stringof); // int function(int)

Re: What is this strange alias syntax?

2011-05-23 Thread Timon Gehr
Steven Schveighoffer wrote: > It is not perfectly consistent. The function type syntax is useless, > because you can only use it if you use the pointer modifier with it. If > you want to declare a function pointer, there are other (better) ways. Yes, other ways of declaring a function pointer ar

Re: What is this strange alias syntax?

2011-05-23 Thread Steven Schveighoffer
On Sun, 22 May 2011 11:20:15 -0400, Timon Gehr wrote: Andrej Mitrovic wrote: Should I file a bug report to kill this syntax? No. It is perfectly valid, see grammar: http://www.digitalmars.com/d/2.0/declaration.html What is strange about this syntax in particular? int i; //declares i of typ

Re: What is this strange alias syntax?

2011-05-22 Thread Andrej Mitrovic
Ah ok. Hey if it's used for something useful I won't steal it from you. ;)

Re: What is this strange alias syntax?

2011-05-22 Thread David Nadlinger
On 5/23/11 8:41 AM, Andrej Mitrovic wrote: On 5/22/11, Timon Gehr wrote: The problem is, that currently there is no other I do not get why anybody would want to remove the possibility to refer to function signatures. What's wrong with using this: alias void function(int, int) funcAlias; It

Re: What is this strange alias syntax?

2011-05-22 Thread Andrej Mitrovic
On 5/22/11, Timon Gehr wrote: > The problem is, that currently there is no other > I do not get why anybody would want to remove the possibility to refer to > function > signatures. What's wrong with using this: alias void function(int, int) funcAlias;

Re: What is this strange alias syntax?

2011-05-22 Thread Timon Gehr
> On 22/05/2011 16:20, Timon Gehr wrote: >> Andrej Mitrovic wrote: >>> Should I file a bug report to kill this syntax? >> >> No. It is perfectly valid, see grammar: >> http://www.digitalmars.com/d/2.0/declaration.html > > Grammar states only that it's syntactically valid, and makes no comment on se

Re: What is this strange alias syntax?

2011-05-22 Thread Stewart Gordon
On 22/05/2011 16:20, Timon Gehr wrote: Andrej Mitrovic wrote: Should I file a bug report to kill this syntax? No. It is perfectly valid, see grammar: http://www.digitalmars.com/d/2.0/declaration.html Grammar states only that it's syntactically valid, and makes no comment on semantic validit

Re: What is this strange alias syntax?

2011-05-22 Thread Timon Gehr
Andrej Mitrovic wrote: > Should I file a bug report to kill this syntax? No. It is perfectly valid, see grammar: http://www.digitalmars.com/d/2.0/declaration.html What is strange about this syntax in particular? int i; //declares i of type "int" alias int i; //defines i as type "int" int func(i

Re: What is this strange alias syntax?

2011-05-22 Thread Andrej Mitrovic
Should I file a bug report to kill this syntax?

Re: What is this strange alias syntax?

2011-05-22 Thread Stewart Gordon
On 22/05/2011 11:57, Steven Schveighoffer wrote: On Sat, 21 May 2011 05:15:32 -0400, Simen Kjaeraas wrote: It's the old C syntax for defining function pointers. Well, without the pointer. And that last part is important, because the latter example is an array of function pointers, with which

Re: What is this strange alias syntax?

2011-05-22 Thread Stewart Gordon
On 21/05/2011 10:15, Simen Kjaeraas wrote: On Sat, 21 May 2011 05:12:20 +0200, Andrej Mitrovic wrote: Taken from the docs: alias int func(int); It's the old C syntax for defining function pointers. Functions, not function pointers. The C syntax for declaring function pointers is i

Re: What is this strange alias syntax?

2011-05-22 Thread Steven Schveighoffer
On Sat, 21 May 2011 05:15:32 -0400, Simen Kjaeraas wrote: On Sat, 21 May 2011 05:12:20 +0200, Andrej Mitrovic wrote: Taken from the docs: alias int func(int); void main() { if ( is(func[]) ) // not satisfied because arrays of writeln("satisfied");// functio

Re: What is this strange alias syntax?

2011-05-21 Thread Simen Kjaeraas
On Sat, 21 May 2011 05:12:20 +0200, Andrej Mitrovic wrote: Taken from the docs: alias int func(int); void main() { if ( is(func[]) ) // not satisfied because arrays of writeln("satisfied");// functions are not allowed else writeln("not satisfied"); }

Re: What is this strange alias syntax?

2011-05-20 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Taken from the docs: > > alias int func(int); > void main() > { > if ( is(func[]) ) // not satisfied because arrays of > writeln("satisfied");// functions are not allowed > else > writeln("not satisfied"); > } > > It will print n

What is this strange alias syntax?

2011-05-20 Thread Andrej Mitrovic
Taken from the docs: alias int func(int); void main() { if ( is(func[]) ) // not satisfied because arrays of writeln("satisfied");// functions are not allowed else writeln("not satisfied"); } It will print not satisfied. But I'm not sure what func is supp

Re: alias syntax

2009-08-05 Thread Ellery Newcomer
> -- > As to your question: > class K{ > alias static int B; > B b; // b is non-static > } > -- > Curious. I didn't actually test the example, but I did for deprecated, and it doesn

Re: alias syntax

2009-08-05 Thread Zarathustra
Ellery Newcomer Wrote: > > You mean how the compiler rejects "alias const int x;" but not "alias > > static int x;"? That is strange.. > > I want to know why > > alias static int x; > > is allowed in the first place d.grammar accepts: alias const int a; but compiler no (it is ok). d.grammar a

Re: alias syntax

2009-08-01 Thread Ellery Newcomer
> You mean how the compiler rejects "alias const int x;" but not "alias > static int x;"? That is strange.. I want to know why alias static int x; is allowed in the first place

Re: alias syntax

2009-08-01 Thread Jarrett Billingsley
On Sat, Aug 1, 2009 at 11:13 PM, Ellery Newcomer wrote: > um, yeah. > > Declaration: >        typedef Decl >        alias Decl >        Decl > > Decl: >        StorageClasses Decl >        BasicType Declarators ; >        BasicType Declarator FunctionBody >        AutoDeclaration > > > Never mind

Re: alias syntax

2009-08-01 Thread Ellery Newcomer
Jarrett Billingsley wrote: > On Sat, Aug 1, 2009 at 8:31 PM, Ellery > Newcomer wrote: >> what is the purpose of the syntax >> >> alias StorageClasses Declarator >> >> ? > > I don't know where you're getting that grammar. Is that from the D spec? um, yeah. Declaration: typedef Decl

Re: alias syntax

2009-08-01 Thread Jarrett Billingsley
On Sat, Aug 1, 2009 at 8:31 PM, Ellery Newcomer wrote: > what is the purpose of the syntax > > alias StorageClasses Declarator > > ? I don't know where you're getting that grammar. Is that from the D spec?

alias syntax

2009-08-01 Thread Ellery Newcomer
what is the purpose of the syntax alias StorageClasses Declarator ? (I just noticed my parser doesn't support it, but I don't see any reason to)