Re: Functions that return type

2016-01-20 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 04:27:27 UTC, blm768 wrote: I guess the constraints are that of a static language. (This is not true.) I'm playing with the design of such a language myself. Basically, anything can create/use/return type objects This is usually possible in dependently

Re: Functions that return type

2016-01-20 Thread BLM768 via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 10:04:03 UTC, burjui wrote: That's alright. Parsing and AST construction are trivial with S-expressions (Lisp-like syntax), so if you use them for the early stages of development, you can focus on the type system. When you're done with types, you can switch to

Re: Functions that return type

2016-01-20 Thread burjui via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 04:27:27 UTC, blm768 wrote: It's not very far along, though. Right now, I have a "compiler" that parses integers and parentheses. ;) That's alright. Parsing and AST construction are trivial with S-expressions (Lisp-like syntax), so if you use them for the

Re: Functions that return type

2016-01-19 Thread Timon Gehr via Digitalmars-d-learn
On 01/17/2016 08:09 PM, data pulverizer wrote: On Sunday, 17 January 2016 at 02:08:06 UTC, Timon Gehr wrote: On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.) Could you please explain? E.g., a few of the systems

Re: Functions that return type

2016-01-19 Thread blm768 via Digitalmars-d-learn
On Sunday, 17 January 2016 at 02:08:06 UTC, Timon Gehr wrote: On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.) I'm playing with the design of such a language myself. Basically, anything can create/use/return type

Re: Functions that return type

2016-01-17 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 17 January 2016 at 02:08:06 UTC, Timon Gehr wrote: On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.) Could you please explain?

Re: Functions that return type

2016-01-16 Thread Timon Gehr via Digitalmars-d-learn
On 01/16/2016 11:50 PM, data pulverizer wrote: I guess the constraints are that of a static language. (This is not true.)

Re: Functions that return type

2016-01-16 Thread Ali Çehreli via Digitalmars-d-learn
On 01/16/2016 02:50 PM, data pulverizer wrote: > I guess I have been writing a lot of julia where I take > creating arrays and tuples of types for granted. In this case > types are of type DataType. [...] I guess the constraints are > that of a static language. Exactly. I am sure every D

Re: Functions that return type

2016-01-16 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } More to the point what is the Type of a type such as int? Thanks p.s. I am aware I could do

Re: Functions that return type

2016-01-16 Thread rsw0x via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } Functions return values, not types. You would use a template to "return" a type

Functions that return type

2016-01-16 Thread data pulverizer via Digitalmars-d-learn
Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } More to the point what is the Type of a type such as int? Thanks

Re: Functions that return type

2016-01-16 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:59:22 UTC, data pulverizer wrote: On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } More to the point what is

Re: Functions that return type

2016-01-16 Thread anonymous via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } No. A function cannot return a type. A template can evaluate to a type, though:

Re: Functions that return type

2016-01-16 Thread sarn via Digitalmars-d-learn
On Saturday, 16 January 2016 at 21:22:15 UTC, data pulverizer wrote: Is it possible to create a function that returns Type like typeof() does? Something such as: Type returnInt(){ return int; } A type itself isn't a runtime value. I think the closest thing is a TypeInfo object: