Re: Scoped Imports for Structs/Classes/Template Constraints

2015-08-31 Thread Enamex via Digitalmars-d-learn
On Monday, 31 August 2015 at 19:10:45 UTC, jmh530 wrote: module local; struct S { int a = 2; } module app; import local : S; void foo(S s) { import std.stdio : writeln; writeln(s.a); } void bar() { import std.stdio : writeln; import local : S; S s;

Re: Scoped Imports for Structs/Classes/Template Constraints

2015-08-31 Thread Enamex via Digitalmars-d-learn
On Monday, 31 August 2015 at 21:22:07 UTC, jmh530 wrote: I'm not sure about how the first local.S resolves things. I had been using a selective import for S before. To get the local.S to compile, I have to change the import to a normal one. I'm concerned about the case where local contains

Re: How to get BaseEnumType?

2015-08-31 Thread Enamex via Digitalmars-d-learn
On Monday, 31 August 2015 at 07:55:53 UTC, drug wrote: Hello I need to get the type to which I can cast the enum for using with foreign library. For example: ``` enum Foo { A = "a", B = "b", } enum Bar { A = 123, B = 432, } static assert(is(BaseEnumType!Foo == string)); static

Re: Scoped Imports for Structs/Classes/Template Constraints

2015-09-01 Thread Enamex via Digitalmars-d-learn
On Tuesday, 1 September 2015 at 15:50:40 UTC, jmh530 wrote: I'm following some of your post, but not quite all of it (particularly the part at the end, and I also think static imports can't be selective). Anyway, I was thinking about something like below as one possible alternative struct T

Re: Scoped Imports for Structs/Classes/Template Constraints

2015-09-01 Thread Enamex via Digitalmars-d-learn
On Tuesday, 1 September 2015 at 21:17:10 UTC, jmh530 wrote: Consider these three different ways to import std.stdio import std.stdio; import std.stdio : writeln; static import std.stdio; and suppose writeln is the only function in std.stdio the program is using. In each case, the size of the

Re: Template detection

2015-09-13 Thread Enamex via Digitalmars-d-learn
On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOne() {} void templatedMethodTwo() {} }

Re: Struct initializers as expressions

2015-12-03 Thread Enamex via Digitalmars-d-learn
On Thursday, 3 December 2015 at 15:31:49 UTC, Chris Wright wrote: On Thu, 03 Dec 2015 06:38:20 +, Mike Parker wrote: AFAIK, your only option is to use a struct constructor. This is the sort of thing they're used for. Which brings be back to positional arguments, which means that

Re: Reset all Members of a Aggregate Instance

2015-12-04 Thread Enamex via Digitalmars-d-learn
On Thursday, 3 December 2015 at 21:04:00 UTC, Nordlöw wrote: ... Unless I'm missing something very important: Isn't that essentially what the `out` attribute on a function parameter does?

Re: Scope of D packages

2015-12-19 Thread Enamex via Digitalmars-d-learn
On Saturday, 19 December 2015 at 00:46:12 UTC, cym13 wrote: To be exact it doesn't need the sources, it needs the function signatures and type definitions so the equivalent of C header files. If you don't want to share the full sources with your library you can generate those header files

Never-returning functions

2016-08-02 Thread Enamex via Digitalmars-d-learn
I've tried to write an 'assert function' in D, one that doesn't trigger the 'function must return a value or assert' error. Basically something like: Never neverReturns() { assert(0); } or @noreturn auto neverReturns() { assert(0); } and int tryMe(bool f) { if(f) return 42; else

Re: Never-returning functions

2016-08-02 Thread Enamex via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 15:18:31 UTC, Steven Schveighoffer wrote: What's wrong with assert(0) that you need to have a wrapper function for it? -Steve Nothing wrong exactly. I just wanted some descriptive terms to use in some places. Like "unreachable()" or "unimplemented()". To be

Re: CT Inheritence structures

2016-08-20 Thread Enamex via Digitalmars-d-learn
On Saturday, 20 August 2016 at 00:46:15 UTC, Engine Machine wrote: I am trying to get Timon Gehr's code working, with some modifications: void main() { import std.traits; auto a = new Type!("Animal", "Dog", "Pug")(); Type!("Animal", "Dog") b = a;