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 type

Re: Doubt - Static multidimension arrays

2016-01-20 Thread Nemo via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 20:39:37 UTC, tsbockman wrote: On Tuesday, 19 January 2016 at 19:14:30 UTC, alb wrote: [...] One other thing you may want to keep in mind when working on this kind of thing - when you loop over a multi-dimensional array, the order matters. For large arrays

Re: Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 19:48:04 UTC, jmh530 wrote: On Wednesday, 20 January 2016 at 19:19:04 UTC, Marc Schütz wrote: On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote: I'm not sure if this is how the behavior is supposed to be or if it is a bug. I believe, however, that it

Re: Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 19:19:04 UTC, Marc Schütz wrote: On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote: I'm not sure if this is how the behavior is supposed to be or if it is a bug. I believe, however, that it _is_ a bug that the imported symbols are visible outside the

Re: Mixin Template Function Attributes

2016-01-20 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote: I'm not sure if this is how the behavior is supposed to be or if it is a bug. It's not a bug. The `@attribute:` syntax applies to all following declarations _inside the current scope_, i.e. until your mixin templates closing `}`.

Re: Mixin Template Function Attributes

2016-01-20 Thread Marc Schütz via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote: I'm not sure if this is how the behavior is supposed to be or if it is a bug. I believe, however, that it _is_ a bug that the imported symbols are visible outside the template. Most likely related to the infamous https://issues.dlan

Re: Distribution of D apps

2016-01-20 Thread Adam D. Ruppe via Digitalmars-d-learn
By default, a binary compiled with D will have the standard library statically linked in, so all you need to distribute are other shared libs you choose to use (which might include curl btw if you use the std.net.curl functions). But many .exes from D can be distributed alone and expected to

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 m

Re: How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread chardetm via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 15:25:10 UTC, Jonathan M Davis wrote: On Wednesday, January 20, 2016 13:06:00 chardetm via Digitalmars-d-learn wrote: Anyone who has the same problem: I found std.range.primitives.hasSlicing (https://dlang.org/phobos/std_range_primitives.html#hasSlicing) which d

Re: Distribution of D apps

2016-01-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/01/16 5:01 AM, Dibyendu Majumdar wrote: Hi, I am trying to understand the options for distributing a D app to users. My assumption is that only the shared libraries and binaries need to be distributed, and I need to include the D libraries. Is this correct? Thanks and Regards Dibyendu B

Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
I was thinking about using mixin templates to put some module-level default information in a single file so that it doesn't clutter up other files. It works for imports, but it doesn't seem to propagate for function attributes. module_default.d --- module module_default; mixin

Distribution of D apps

2016-01-20 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi, I am trying to understand the options for distributing a D app to users. My assumption is that only the shared libraries and binaries need to be distributed, and I need to include the D libraries. Is this correct? Thanks and Regards Dibyendu

Re: How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 20, 2016 13:06:00 chardetm via Digitalmars-d-learn wrote: > Anyone who has the same problem: I found > std.range.primitives.hasSlicing > (https://dlang.org/phobos/std_range_primitives.html#hasSlicing) > which does exactly what I want! Note that because strings are treated as

Re: Overload dispatch by templated interface type doesn't seem to work

2016-01-20 Thread QAston via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 14:01:23 UTC, QAston wrote: To me this suggests that the dispatch by templated interface type Visitor!(RETURN) doesn't work. IMO the order of interfaces shouldn't matter here and the code should simply work. Any ideas? I'm on 2069.2 and when i remove one of t

Overload dispatch by templated interface type doesn't seem to work

2016-01-20 Thread QAston via Digitalmars-d-learn
Hi, I have the following code: interface Visitable(RETURN) { RETURN accept(Visitor!RETURN); } interface Exp : Visitable!string, Visitable!int { } interface Visitor(RETURN) { RETURN visitLit(Lit e); RETURN visitAdd(Add e); } class Lit : Exp { int val;

Re: Function accepting variadic arguments

2016-01-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 13:09:13 UTC, Daniel Kozak wrote: On Wednesday, 20 January 2016 at 13:06:14 UTC, pineapple wrote: On Wednesday, 20 January 2016 at 12:56:51 UTC, Ali Çehreli wrote: And there is another example here: http://ddili.org/ders/d.en/templates_more.html#ix_templates_m

Re: Function accepting variadic arguments

2016-01-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 13:06:14 UTC, pineapple wrote: On Wednesday, 20 January 2016 at 12:56:51 UTC, Ali Çehreli wrote: And there is another example here: http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.tuple%20template%20parameter Ali Thank you! What's the purpo

Re: Function accepting variadic arguments

2016-01-20 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 13:04:23 UTC, Daniel Kozak wrote: V Wed, 20 Jan 2016 12:38:20 + pineapple via Digitalmars-d-learn napsáno: import std.stdio; struct S { this(Args...)(Args args) { foreach(Type, Value;args) { writefln("Type: %s value: %

Re: Function accepting variadic arguments

2016-01-20 Thread pineapple via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 12:56:51 UTC, Ali Çehreli wrote: And there is another example here: http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.tuple%20template%20parameter Ali Thank you! What's the purpose of "is" in the type checks? Also, how would I utilize isNumer

Re: How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread chardetm via Digitalmars-d-learn
Anyone who has the same problem: I found std.range.primitives.hasSlicing (https://dlang.org/phobos/std_range_primitives.html#hasSlicing) which does exactly what I want!

Re: Function accepting variadic arguments

2016-01-20 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 20 Jan 2016 12:38:20 + pineapple via Digitalmars-d-learn napsáno: > I'd like to make a constructor which takes a variable list of > arguments, of a short list of possible types, with different > handling depending on the type. I haven't been able to find any > documentation or examp

Re: Function accepting variadic arguments

2016-01-20 Thread Ali Çehreli via Digitalmars-d-learn
On 01/20/2016 04:38 AM, pineapple wrote: I'd like to make a constructor which takes a variable list of arguments, of a short list of possible types, with different handling depending on the type. I haven't been able to find any documentation or examples that did quite what I'm trying to. Help? A

Function accepting variadic arguments

2016-01-20 Thread pineapple via Digitalmars-d-learn
I'd like to make a constructor which takes a variable list of arguments, of a short list of possible types, with different handling depending on the type. I haven't been able to find any documentation or examples that did quite what I'm trying to. Help? A fun pseudocode example of what I'm try

Re: How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread chardetm via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 10:44:36 UTC, Rikki Cattermole wrote: template CanSlice(T) { enum CanSlice = __traits(compiles, {T t; auto v = t[0 .. 1];}) || __traits(compiles, {T t; auto v = t.opSlice();}); } Should work. Thanks it works just fine!

Re: How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 20/01/16 11:41 PM, chardetm wrote: Hi everyone, I was wondering if it was possible to know at compile time if opSlice is defined for a type, including built-in types like "string". Here is the code I have: import std.stdio; struct Test { Test opSlice(size_t i, size_t j) { ret

How to know if opSlice is defined for a type (including built-in types)?

2016-01-20 Thread chardetm via Digitalmars-d-learn
Hi everyone, I was wondering if it was possible to know at compile time if opSlice is defined for a type, including built-in types like "string". Here is the code I have: import std.stdio; struct Test { Test opSlice(size_t i, size_t j) { return this; // We don't care

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 earl

Re: Partial application of compile time args type deduction

2016-01-20 Thread QAston via Digitalmars-d-learn
On Wednesday, 20 January 2016 at 00:50:49 UTC, Ali Çehreli wrote: On 01/19/2016 04:22 PM, QAston wrote: [...] Is this it? If so, is it already in std.functional? (I could not find it. :) ) auto appendMapped(alias f, R, T)(R r, T elem) { r ~= f(elem); return r; } int minus(int i) {