Re: Extend the call site default argument expansion mechanism?
On Tuesday, 15 May 2018 at 20:31:14 UTC, jmh530 wrote: On Tuesday, 15 May 2018 at 15:02:36 UTC, jmh530 wrote: [snip] Note, it's not an issue if Foo were not a struct. This was fixed in Bug 6400 [1]l. The issue is with template instances. I have filed a new enhancement request [2] [1] https://issues.dlang.org/show_bug.cgi?id=6400 [2] https://issues.dlang.org/show_bug.cgi?id=18863 Interestingly, you can get pretty close with a struct nested in a template function, however it seems that overload resolution does not check opDispatch if a public symbol of the same name exists. this (https://run.dlang.io/is/ZzfWDs) dosen't work, but this (https://run.dlang.io/is/7zvfqc) does (notice SList & DList are not directly visible).
Re: dub should be more command-line oriented
On Wednesday, 10 January 2018 at 15:07:40 UTC, Luís Marques wrote: I often feel that dub relies too much on dub.[json|sdl] and too little on command-line switches. Here's the latest example: [...] You could just make a refactoring configuration and use the --config flag to specify it when necessary. (see: https://code.dlang.org/package-format?lang=json#configurations)
Re: [OT] Windows dying
On Friday, 3 November 2017 at 18:26:54 UTC, Joakim wrote: On Friday, 3 November 2017 at 18:08:54 UTC, 12345swordy wrote: On Friday, 3 November 2017 at 17:25:26 UTC, Joakim wrote: Most programmers will one day be coding on mobile devices, though I admit I'm in a small, early-adopting minority now: http://bergie.iki.fi/blog/six-weeks-working-android/ A blog post is not evidence that the majority of programmers will be coding on mobile devices. Yes, but it is evidence of what I said, that "I'm in a small, early-adopting minority now." I don't know how you expect evidence for something that _will_ happen, it's a prediction I'm making, though based on current, rising trends like all those in this feed: https://mobile.twitter.com/termux Can we please get back on topic please? Whether or not windows is 'dying' is irrelevant, since it is not going to die out as a development platform for at least the next 5 years. I, like many other windows users, want to be able to compile 64bit binaries in windows, without having to download and install the bloated and time consuming to download and install Visual Studio. I do most of my programming in Sublime Text, and frequently re-install windows. This may not be the case for many windows users of D, but clearly many windows users of D would like to be able to compile x64 out of the box.
Re: isInputRange as a __traits ?
On Saturday, 7 October 2017 at 10:31:01 UTC, user1234 wrote: Since the compiler has the ability to detect input ranges in the foreach aggregate that are aggregates implementing the right primitives, why don't you set the widely used std.range.isInputRange as a __trait, e.g __traits(isInputRange, Stuff) ? Because the __traits expression is supposed to be a fallback in place of where std.traits cannot be used, and should see minimum use.
Re: code.dlang.org is offline?
On Friday, 22 September 2017 at 08:14:43 UTC, Szabo Bogdan wrote: Hi, Is there a reason why code.dlang.org is offline? Thanks, Bogdan Well, it seems to be working now.
Re: Templates, D way
On Tuesday, 5 September 2017 at 12:54:20 UTC, Void-995 wrote: On Tuesday, 5 September 2017 at 12:20:14 UTC, crimaniak wrote: On Tuesday, 5 September 2017 at 11:08:57 UTC, Void-995 wrote: @property mixin(DataList!("firstSublist", MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset)); I don't think string mixins are required here. It seems just template is more simple. T[] getBytesAs(T, alias length, alias offset)() { return (cast(T *)(cast(byte *)(&this) + offset))[0 .. length]; } struct MyBinaryStructA { ... alias firstList = getBytesAs!(MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset); alias secondList = getBytesAs!(MyBinarySubStructBForA, secondSublistMembersCount, secondSublistMembersOffset); } unittest { ... MyBinaryStructA *binaryData = cast(MyBinaryStructA *)fileData.ptr; auto a = binaryData.firstList; } Thanks, that definitely working and doesn't require mixin with strings. But while waiting for response I've tried another thing, and I doubt I would able do to that without string now: template MyBinaryStructGenericDataList(string listName, alias Type) { import std.string; const char[] MyBinaryStructGenericDataList = format(q{ int %sCount; int %sOffset; @property %s[] %s() const { return (cast(%s *)(cast(ubyte *)(&this) + %sOffset))[0 .. %sCount]; } }, listName, listName, Type.stringof, listName, Type.stringof, listName, listName); } struct MyBinarySubStructAForA { int someIntegerFieldA; float someFloatFieldA; } struct MyBinarySubStructBForA { int someIntegerFieldB; float someFloatFieldB; } struct MyBinaryStructA { mixin(MyBinaryStructGenericDataList!("firstSublist", MyBinarySubStructAForA)); mixin(MyBinaryStructGenericDataList!("secondSublist", MyBinarySubStructBForA)); } ... MyBinaryStructA *binaryData = cast(MyBinaryStructA *)fileData.ptr; ... Yes, there is definately no other way but to use string mixins here, however if you switch to a mixin template, and put the string mixin inside of that, you don't have to do text replacement to use the template parameters. Example: mixin template GenericDataList(string name, T) { mixin(` int `~name~`SublistCount; int `~name~`SublistOffset; @property auto `~name~`Sublist() { return (cast(T*)(cast(byte*)&this + `~name~`SublistOffset))[0..`~name~`SublistCount]; }`); } struct MyBinarySubStructAForA { int someIntegerFieldA; float someFloatFieldA; } struct MyBinarySubStructBForA { int someIntegerFieldB; float someFloatFieldB; } struct MyBinaryStructA { mixin MyBinaryStructGenericDataList!("first", MyBinarySubStructAForA); mixin MyBinaryStructGenericDataList!("second", MyBinarySubStructBForA); }
Re: Templates, D way
On Tuesday, 5 September 2017 at 12:20:14 UTC, crimaniak wrote: On Tuesday, 5 September 2017 at 11:08:57 UTC, Void-995 wrote: @property mixin(DataList!("firstSublist", MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset)); I don't think string mixins are required here. It seems just template is more simple. T[] getBytesAs(T, alias length, alias offset)() { return (cast(T *)(cast(byte *)(&this) + offset))[0 .. length]; } struct MyBinaryStructA { ... alias firstList = getBytesAs!(MyBinarySubStructAForA, firstSublistMembersCount, firstSublistMembersOffset); alias secondList = getBytesAs!(MyBinarySubStructBForA, secondSublistMembersCount, secondSublistMembersOffset); } unittest { ... MyBinaryStructA *binaryData = cast(MyBinaryStructA *)fileData.ptr; auto a = binaryData.firstList; } I find it very strange that this works, as a non-mixin template should not be able to capture the context of where it was instantiated. If you take the alias template parameters out it behaves how it should (that is an error message saying this is not accessible).