Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
@AliCehreli: you may consider including Jonathan's trick in your book in the para above this heading: http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.variable, %20immutable Jonathan M Davis via Digitalmars-d-learn wrote: > yes, having > > enum s = ta("s)"; > > and

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
ag0aep6g wrote: > On 03.03.2016 07:12, Shriramana Sharma wrote: >> string ta(string s) { return s ~ "1"; } >> template ta(string s) { enum ta = ta(s); } > > In `ta(s)` here, `ta` is the enum itself again. It's similar to `int x = > x;`. Can't do that, of course. > > Add a leading dot to refer

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread aki via Digitalmars-d-learn
On Friday, 4 March 2016 at 16:46:35 UTC, Steven Schveighoffer wrote: You cannot add or remove keys. You can modify values for existing keys. Note, in your code, this would not cause a problem, since setting hash to null just removes the reference from the local variable 'hash', it does not

Re: Unable to instantiate template with same name as function

2016-03-04 Thread Shriramana Sharma via Digitalmars-d-learn
cym13 wrote: > Note that parentheses are optional when no argument is provided. Yes I know that but the point is I expected the compiler to identify ta!"string" to refer to a different symbol than ta("string") where the one is obviously a template and the other is obviously a function call.

Re: D thinks it is OK to mess around with TypeInfo

2016-03-04 Thread Rikki Cattermole via Digitalmars-d-learn
On 05/03/16 10:35 AM, Yuxuan Shui wrote: For example struct A{} @safe void main(){ import std.stdio; A a, b; auto y = typeid(a); y.name = "Nope, I'm not A"; auto x = typeid(b); writeln(x); } Make changes to TypeInfo will affect all the future typeid() results! And

D thinks it is OK to mess around with TypeInfo

2016-03-04 Thread Yuxuan Shui via Digitalmars-d-learn
For example struct A{} @safe void main(){ import std.stdio; A a, b; auto y = typeid(a); y.name = "Nope, I'm not A"; auto x = typeid(b); writeln(x); } Make changes to TypeInfo will affect all the future typeid() results! And D is OK with that?

Re: Is it safe to use 'is' to compare types?

2016-03-04 Thread Yuxuan Shui via Digitalmars-d-learn
On Friday, 4 March 2016 at 15:18:55 UTC, Steven Schveighoffer wrote: On 3/3/16 6:58 PM, Yuxuan Shui wrote: On Thursday, 3 March 2016 at 23:51:16 UTC, Adam D. Ruppe wrote: On Thursday, 3 March 2016 at 23:46:50 UTC, Yuxuan Shui wrote: Will typeid(a) is typeid(b) yield different results than

Re: std.range: Lockstep vs. Zip

2016-03-04 Thread Seb via Digitalmars-d-learn
On Thursday, 3 March 2016 at 15:00:10 UTC, Alex Parrill wrote: On Wednesday, 2 March 2016 at 08:51:07 UTC, Manuel Maier wrote: Hi there, I was wondering why I should ever prefer std.range.lockstep over std.range.zip. In my (very limited) tests std.range.zip offered the same functionality as

Re: In language tooling

2016-03-04 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 02:36:50 UTC, Charles wrote: is this something that could be accomplished in D with CTFE? I think I've heard him say that tools should be part of the language. However, I haven't watched that video and anyway am not sure how important CTFE would be to this

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/4/16 8:53 AM, aki wrote: Is it okay to modify associative array while iterating it? import std.stdio; void main() { string[string] hash = [ "k1":"v1", "k2":"v2" ]; auto r = hash.byKeyValue(); while(!r.empty) { auto key = r.front.key; auto value =

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread Mike Parker via Digitalmars-d-learn
On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote: Is it okay to modify associative array while iterating it? import std.stdio; void main() { string[string] hash = [ "k1":"v1", "k2":"v2" ]; auto r = hash.byKeyValue(); while(!r.empty) { auto key =

Re: Is it safe to use 'is' to compare types?

2016-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/3/16 6:58 PM, Yuxuan Shui wrote: On Thursday, 3 March 2016 at 23:51:16 UTC, Adam D. Ruppe wrote: On Thursday, 3 March 2016 at 23:46:50 UTC, Yuxuan Shui wrote: Will typeid(a) is typeid(b) yield different results than typeid(a) == typeid(b)? No. Indeed, opEquals on TypeInfo just calls is

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread JR via Digitalmars-d-learn
On Friday, 4 March 2016 at 14:16:55 UTC, Minas Mina wrote: On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote: I think what you can do is extract its contents to an array, iterate it and modify it as you like, and then insert back to another associative array. I don't think it's efficient but

Re: efficient and safe way to iterate on associative array?

2016-03-04 Thread Minas Mina via Digitalmars-d-learn
On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote: Is it okay to modify associative array while iterating it? import std.stdio; void main() { string[string] hash = [ "k1":"v1", "k2":"v2" ]; auto r = hash.byKeyValue(); while(!r.empty) { auto key =

efficient and safe way to iterate on associative array?

2016-03-04 Thread aki via Digitalmars-d-learn
Is it okay to modify associative array while iterating it? import std.stdio; void main() { string[string] hash = [ "k1":"v1", "k2":"v2" ]; auto r = hash.byKeyValue(); while(!r.empty) { auto key = r.front.key; auto value = r.front.value;

Re: In language tooling

2016-03-04 Thread Charles via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 03:41:57 UTC, sigod wrote: Very interesting. I wonder what Walter would say about it. Yeah, I'm curious what others' thoughts on it are for sure.