Re: enums

2014-05-31 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 31 May 2014 at 22:13:35 UTC, monarch_dodra wrote: On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote: 'enum' as a manifest constant keyword has been an unpopular decision from its introduction. "Everybody" agrees that it should be changed. Everybody but Walter I find

Re: enums

2014-06-01 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 31 May 2014 at 22:45:32 UTC, bearophile wrote: Chris Nicholson-Sauls: Good... I was starting to fear I was the only one. In general you can't fix the names in a language because you always find someone that likes the ones present :) I think "enum" is a bad name for the purpose

Re: support for unicode in identifiers

2014-06-01 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Sunday, 1 June 2014 at 22:26:42 UTC, Vlad Levenfeld wrote: I was pretty happy to find that I could use mu and sigma when writing statistical routines, but I've found that for more obscure non-ascii characters the support is hit or miss. For example, none of the subscripts are valid character

Re: next!T

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 7 June 2014 at 02:23:18 UTC, Andrew Edwards wrote: This function now works for all types except dstring. This remains a problem I cannot figure out. The error code is as follows: $ rdmd -unittest textnext /usr/share/dmd/src/phobos/std/conv.d(3293): Error: cannot modify immutabl

Re: Creating new types from tuples.

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 6 June 2014 at 23:44:04 UTC, Evan Davis wrote: Hello, I'm looking to use the Tuple type as a way of generating types to represent data in a send recieve connection pair. I created a template to try this: template s_to_c(UDP packetType) { static if (packetType == UDP.ping

Re: next!T

2014-06-06 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 7 June 2014 at 03:21:49 UTC, Andrew Edwards wrote: Wow. Sometimes you really cannot see the things you type no matter how long you stare at it. Thank you soo much. No problem. I only noticed when I re-typed it by hand to study the flow, and instinctively added the else out of

Re: Using attributes inside template instantiation

2014-06-25 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
UDA's are compile-time metadata associated with a specific declaration. So in something like: @foo int x; The @foo is attached to x, but is not part of the type.

Re: Using two flags in conditonal compilation (version)

2014-06-25 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
version(DigitalMars) version = DMDAsm; version(LDC) version = DMDAsm; version(DMDAsm) asm { //dmd/ldc asm here } version(GDC) asm { //gdc asm here } http://dlang.org/version.html#VersionSpecification

Re: Using attributes inside template instantiation

2014-06-25 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 17:21:21 UTC, H. S. Teoh via Digitalmars-d-learn wrote: The term "attribute" is a bit confusing, especially since "property" is also used in the language to refer to something completely different. A better term is perhaps "annotation". The @foo is an annotation

Re: close program by code

2014-06-26 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Thursday, 26 June 2014 at 11:07:37 UTC, Rene Zwanenburg wrote: They won't. Same for module destructors. If you need those to work, another option is to throw some custom Exception type which is only caught in main. I really wish this wasn't the answer, but for some programs I've had to r

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 07:43:27 UTC, Uranuz wrote: I don't know why I use D enough long but I did not remember this fact. Sometimes we get spoiled by all the amazing/nifty things that do work, and expect comparable things like this to Just Work. To be honest, at first I didn't see any is

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 14:27:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Try this: Get out of my head!

Re: import except one?

2014-06-27 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Friday, 27 June 2014 at 05:26:09 UTC, Puming wrote: On Thursday, 26 June 2014 at 08:02:24 UTC, bearophile wrote: Puming: I'm using scriptlike, which imports everything from std.process for convienience, but I also need to import another module, which contains a class `Config`, it conflicts

Re: delegates & GC allocations

2014-08-20 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 15:17:52 UTC, Ola Fosheim Gr wrote: non-static nested functions are effectively delegates as it needs a context pointer to parent stack frame. Only if it is recursive. Or if it refers to any state of the parent function.

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
class A { string getName(this Klass)() { return Klass.stringof; } } class B : A {} void main() { import std.stdio; auto a = new A; auto b = new B; writeln(a.getName()); writeln(b.getName()); } ## This i

Re: Novice web developer trying to learn D

2014-09-07 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
There's Adam Ruppe's excellent "D Cookbook" available here: https://www.packtpub.com/application-development/d-cookbook And since you specifically said "web developer" I hope you're looking at vibe.d: http://vibed.org/

Re: Code fails with linker error. Why?

2014-10-04 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
In the original you are casting an int to a pointer type, which is legitimate (although rarely a good idea). The other side of the matter is simply precedence. cast(T)a.b; Is really the same as: cast(T)(a.b);

Re: Recursive template

2014-11-15 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
Slightly simpler: struct SomeType(K, V) {} alias X(V) = V; alias X(V, K...) = SomeType!(K[0], X!(V, K[1 .. $])); That's a recurring pattern to get used to: aliasing away to one of the parameters in a terminal and/or degenerate case. Also: that an empty tuple matches no parameter "m

Re: Simple code sample of Nesting Structures. I'm I doing something illegal here?

2014-11-22 Thread Chris Nicholson-Sauls via Digitalmars-d-learn
On Saturday, 22 November 2014 at 20:57:07 UTC, WhatMeWorry wrote: auto bottom = NestedBottom(2, ['d','o','g']); That 'auto' is the problem. You want 'this.bottom = ...' instead.