Re: Binding to GSL library

2015-11-26 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/15 17:11, Radek via Digitalmars-d-learn wrote: > Hi, I'm making a trying to bind a gsl library > http://www.gnu.org/software/gsl/ so far it was working but when i started > binding complex numbers some functions won't work, like trigonometric > functions - called they return null. > >

Re: Forward declaration issue

2015-12-04 Thread Artur Skawina via Digitalmars-d-learn
On 12/04/15 09:12, Andre via Digitalmars-d-learn wrote: > Hi, > > I have a strange issue with following coding. > > void baz(); // forward declaration > > void foo() > { > void bar() > { > baz(); // (1) without f.d. syntax error > } > > void baz() > { > b

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: > Thanks! I was surprised this is not straightforward. enum isLvalue(alias A) = is(typeof((ref _){}(A))); artur

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: > On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote: >> On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: >>> Thanks! I was surprised this is not straightforward. >> >>enum isLvalue(alias A) = is(typeof((r

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 21:42, Artur Skawina wrote: > On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: >> That looks much nicer. It still needs work to properly handle functions with >> non-empty argument lists. > > Then it gets a bit long for a one-liner ;) > >enum isLvalue(A...) = is(typeof((ref

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 15:02, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote: >> On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: >>> It would be nice to have a simple writeln that adds spaces automatically >>> like Python's 'print' in std.stdio

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 16:32, Artur Skawina wrote: > >void print(A...)(A a) { > foreach (N, ref e; a) > write(e, N==A.length-1?"\n":" "); >} BTW, that was *deliberately* written that way as a compromise between efficiency and template bloat. It can of course be done like void prin

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 18:53, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote: >> On 02/04/16 16:32, Artur Skawina wrote: >> but that seems too expensive, when the use is just in toy programs and >> debugging. > > I hadn't really considered the relativ

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 08:04, cy via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote: >>void print(A...)(A a) { >> foreach (N, ref e; a) >> write(e, N==A.length-1?"\n":" "); >>} > >>> will be unrolled at compile time > > Mind if I elabora

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: >> call used to print diagnostics. What I saw made me never use or look at D's >> std lib again. Except for meta programing and toy/example programs where it >>

Re: Decoding Pattern to a Tuple

2016-02-22 Thread Artur Skawina via Digitalmars-d-learn
On 02/19/16 19:10, Nordlöw via Digitalmars-d-learn wrote: > Have anybody put together a generalised form of findSplit that can split and > decode using a compile time parameters somewhat like > > "(1)-(2.0)".decode!("(", int, ")", char, "(", double, ")") > > evaluates to > > to a > > tuple!(in

Re: static if else behavior and is type comparison

2016-03-11 Thread Artur Skawina via Digitalmars-d-learn
On 03/11/16 09:21, Ali Çehreli via Digitalmars-d-learn wrote: > You've been bitten by a common usability issue. :) > > On 03/11/2016 12:02 AM, Fynn Schröder wrote: >> static if (is(U == ubyte)) { >> } else if (is(U == ushort)) { > > You mean 'else static if'. (Not your fault: I (and ot

Re: Issue Turning Template into Variadic Template

2016-03-31 Thread Artur Skawina via Digitalmars-d-learn
On 03/30/16 20:12, jmh530 via Digitalmars-d-learn wrote: > I wrote a version of cartesianProduct that will return the cartesian product > when the some of the types are not ranges. The original code is below. > > My issue is that I can't figure out how to turn it into a variadic template. > auto

Re: a lambda with arguments has type void?

2016-06-09 Thread Artur Skawina via Digitalmars-d-learn
On 06/09/16 07:20, cy via Digitalmars-d-learn wrote: > Like this is why it doesn't really make sense: > > import std.stdio; > > auto foo(Callable)(Callable c) { > return c(42); > } > > auto foo2(alias c)() { > return c(42); > } > > void main() { > // this works, when you know it's an int

Re: import with renaming and public import inside module

2014-04-29 Thread Artur Skawina via Digitalmars-d-learn
On 04/29/14 11:57, ketmar via Digitalmars-d-learn wrote: > On Monday, 28 April 2014 at 15:57:16 UTC, anonymous wrote: >> `zmod.symbol` works, too. > no, it's not. at least on latest GDC. It certainly works here; if it didn't it would be a frontend problem. >> I don't think so. The point of the re

Re: Making enum join variadic

2014-05-01 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/14 00:24, "Nordlöw" via Digitalmars-d-learn wrote: > How can I make `join` variadic (by filling in njoin) in the following code? import std.array, std.range, std.algorithm; import std.stdio; template Njoin(ES...) { mixin({ string r = "enum Njoin { "; fore

Re: Making enum join variadic

2014-05-02 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/14 15:38, "Nordlöw" via Digitalmars-d-learn wrote: > > template MemberNamesUnion(E...) if (allSatisfy!(isEnum, E)) > { > bool[string] allMembers; // used to detect member collisions > mixin({ > string r = "enum MemberNamesUnion { "; > foreach (T; E) { >

Re: Making enum join variadic

2014-05-02 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/14 17:27, Meta via Digitalmars-d-learn wrote: > On Friday, 2 May 2014 at 15:18:06 UTC, Artur Skawina via Digitalmars-d-learn > wrote: >> On 05/02/14 15:38, "Nordlöw" via Digitalmars-d-learn wrote: >>> >>> template MemberNamesUnion(E...) if (al

Re: Postblit not invokable with MyStruct(MyStruct()); ?

2014-05-03 Thread Artur Skawina via Digitalmars-d-learn
On 05/03/14 01:05, Mark Isaacson via Digitalmars-d-learn wrote: > 2) I ran into this issue while attempting to leverage the postblit for > code-reuse. In particular, I have a setup that is similar to: > > struct A { > this(B b) { /* Stuff */ } > } > > struct B { > } > > void foo(T)(T param) {

Re: Need help with movement from C to D

2014-05-06 Thread Artur Skawina via Digitalmars-d-learn
I'm not sure why you'd want to wrap the .offsetof expression in a template, but it can easily be done like this: enum offsetOf(alias A, string S) = mixin("A."~S~".offsetof"); Keep in mind that D's offsetof is flawed - if the object does not contain the requested member, but implicitly convert

Re: Need help with movement from C to D

2014-05-06 Thread Artur Skawina via Digitalmars-d-learn
On 05/06/14 16:45, via Digitalmars-d-learn wrote: > On Tuesday, 6 May 2014 at 14:25:01 UTC, Artur Skawina via Digitalmars-d-learn > wrote: >> I'm not sure why you'd want to wrap the .offsetof expression in >> a template, but it can easily be done like this: >> &

Re: Temporary silence output (stdout)

2014-05-10 Thread Artur Skawina via Digitalmars-d-learn
On 05/10/14 22:24, MarisaLovesUsAll via Digitalmars-d-learn wrote: > I sometimes got a useless messages in stdout from SDL_Image > library, and I want to temporary silence it. How do I do? One way would be something like: import std.stdio; void writeOutput () { static c = 1; pr

Re: [Rosettacode] Growable slices

2014-05-16 Thread Artur Skawina via Digitalmars-d-learn
On 05/16/14 11:47, bearophile via Digitalmars-d-learn wrote: >> There are of course ways to implement a really efficient ZLW compressor in >> D, and such implementation could be added as third D entry if it manages to >> be not too much long, > > Third version added: > http://rosettacode.org/wik

Re: [Rosettacode] Growable slices

2014-05-16 Thread Artur Skawina via Digitalmars-d-learn
On 05/16/14 17:20, bearophile via Digitalmars-d-learn wrote: > Artur Skawina: > >> Ugh. So how does it perform wrt the D version that I wrote for >> you last time? [1] > > I have done a benchmark with the various version (the first 3 are the ones on > the Rosettacode site, and the #4 is yours):

Re: alias with lambda syntax: alias fun2=a=>fun(a);

2014-06-05 Thread Artur Skawina via Digitalmars-d-learn
On 06/05/14 08:58, Timothee Cour via Digitalmars-d-learn wrote: > Is there a way to do this? > > auto fun(T)(T a){return a;} > > template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and > cannot be nested inside test() alias fun2(T) = fun!T; But this will prevent IFTI, so

Re: alias with lambda syntax: alias fun2=a=>fun(a);

2014-06-05 Thread Artur Skawina via Digitalmars-d-learn
> On 06/05/14 08:58, Timothee Cour via Digitalmars-d-learn wrote: >> //none of those work: >> //alias fun2=a=>fun(a); alias fun2=ALIAS!(a=>fun(a)); That 'ALIAS' template will need to be in module scope. alias ALIAS(alias A) = A; artur

Re: enum template shorthand and short circuit evaluation

2014-06-10 Thread Artur Skawina via Digitalmars-d-learn
On 06/10/14 02:28, Byron via Digitalmars-d-learn wrote: > Should this work? It seems like the short circuit booleans are not > working: > > enum isPrimitive(T) = isBasicType!T || (isArray!T && isBasicType! > (ForeachType!T)); [...] > But this style works: > > template isPrimitive(T) > { >

Re: Splitting Ranges using Lambda Predicates

2014-06-11 Thread Artur Skawina via Digitalmars-d-learn
On 06/11/14 00:31, "Nordlöw" via Digitalmars-d-learn wrote: >> Either way, it shouldn't be too hard to implement. Base it off >> "splitter!pred", which is actually quite trivial. AFAIK, your > > What do you mean by basing it off splitter!pred - should I start with some > existing splitter algori

Re: Splitting Ranges using Lambda Predicates

2014-06-11 Thread Artur Skawina via Digitalmars-d-learn
On 06/11/14 14:40, monarch_dodra via Digitalmars-d-learn wrote: > For example, you should avoid "countUntil" and "takeExactly" when dealing > with strings, since these are not O(1) operations, and don't actually return > string slices. EG: > string s = "someGGGreatVariableName".slicer().front; >

Re: Splitting Ranges using Lambda Predicates

2014-06-11 Thread Artur Skawina via Digitalmars-d-learn
On 06/11/14 15:44, Artur Skawina wrote: > If, instead, you create a string-specific 'countUntil' that returns > a type that holds both the byte and code-point counts and implicitly > converts to the latter, then you can have a 'takeExactly' overload > that uses the extra info to avoid the unnecessa

Re: Splitting Ranges using Lambda Predicates

2014-06-11 Thread Artur Skawina via Digitalmars-d-learn
On 06/11/14 16:05, monarch_dodra via Digitalmars-d-learn wrote: > Well, (IMO) it's a problem with no real solution. But for what it's worth, > most (if not all) of the algorithms in the standard lib know how to handle > strings efficiently and correctly (split, find, etc...). Things only start >

Re: C++'s "defaulted comparison operators" proposal

2014-06-18 Thread Artur Skawina via Digitalmars-d-learn
On 06/18/14 07:49, Ali Çehreli via Digitalmars-d-learn wrote: > The idea is to be able to have standard comparison behavior for structs > without boilerplate. For example, if the ordering should consider all members > of the following struct one after the other (first 'i', then 'l', and finally

Re: C structs

2014-06-21 Thread Artur Skawina via Digitalmars-d-learn
On 06/20/14 14:42, Dicebot via Digitalmars-d-learn wrote: > On Friday, 20 June 2014 at 12:17:22 UTC, Johann Lermer wrote: >> So, why is there no init routine for the rectangle? There's only one for the >> matrix. > > That needs actually building deimos cairo and checking symbols in object > file

Re: template mixins for boilerplate

2014-06-21 Thread Artur Skawina via Digitalmars-d-learn
On 06/21/14 05:32, Paul D Anderson via Digitalmars-d-learn wrote: > I can't use a template mixin: > > mixin template Function(string name) > { > const char[] Function = > "public static int " ~ name ~ "() { return other.module." ~ name ~"; }"; > } > > Error: mixin templates are not regular

Re: template mixins for boilerplate

2014-06-21 Thread Artur Skawina via Digitalmars-d-learn
On 06/21/14 18:01, Philippe Sigaud via Digitalmars-d-learn wrote: > In what way is a template more reliable than the equivalent function? > mixin template Function(string name) { > mixin("public static int " ~ name ~ "() { return other.module." ~ > name ~"; }"); > } > > struct S { > mix

Re: Compile time regex matching

2014-07-14 Thread Artur Skawina via Digitalmars-d-learn
On 07/14/14 13:42, Philippe Sigaud via Digitalmars-d-learn wrote: > asserts get an entire copy of the parse tree. It's a bit wasteful, but > using 'immutable' directly does not work here, but this is OK: > > enum res = MyRegex("abcabcdefFOOBAR"); // compile-time parsing > immutable result

Re: Showing a user specified error message when no overloads match

2014-07-29 Thread Artur Skawina via Digitalmars-d-learn
On 07/29/14 17:45, H. S. Teoh via Digitalmars-d-learn wrote: > You're right, opDispatch behaves like SFINAE. I've had trouble debugging > it before, because when it works, it works very well, but when you > accidentally make a typo, it just "disappears" -- you get an error that > the property is mi

Re: auto ref function parameters in a free function

2014-08-03 Thread Artur Skawina via Digitalmars-d-learn
On 08/03/14 23:19, Vlad Levenfeld via Digitalmars-d-learn wrote: > > I made less_than to serve as a default sorting predicate, so in a few places > there is something like this: > > void sort (R, T = ElementType!R, alias compare = less_than!T)(R range, T item) > {...} void sort (R, T = Element

Re: Inner struct accessing host member

2014-08-05 Thread Artur Skawina via Digitalmars-d-learn
On 08/05/14 22:32, Philippe Sigaud via Digitalmars-d-learn wrote: > I'd have thought that this would work: > > struct A > { > int[] i; > B b; > > struct B > { > void foo() { i ~= 1;} > } > } > > void main() > { > A a; > a.b.foo(); > } > > But the compiler tel

Re: opDispatch compiles fine, but still fails to resolve?

2014-08-09 Thread Artur Skawina via Digitalmars-d-learn
On 08/09/14 03:20, Vlad Levenfeld via Digitalmars-d-learn wrote: > More opDispatch woes. This feature keeps biting me, yet I keep trying to use > it. > > This time I'm trying to access elements of a vector GLSL-style (without > swizzling... for now). > > Here's the relevant code: > > struct Ve

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote: > We indeed need to put annotations inside aggregates to > affect their innards. > > If that's true, I have a lot of annotation sprinkling to do. It's not true for @safe, but true for some other attributes. http://forum.dlang.org/

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: > On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn >> http://forum.dlang.org/post/mailman.125.1397731134.2763.digitalmar...@puremagic.com > > Okay... > > So @safe includes child scope

Re: Error with constraints on a templated fuction

2014-08-25 Thread Artur Skawina via Digitalmars-d-learn
On 08/25/14 18:52, Jonathan M Davis via Digitalmars-d-learn wrote: > Another commonly used one is is(typeof(foo)). typeof(foo) gets the type of foo > and will result in void if foo doesn't exist, and is(void) is false, whereas D is not quite that simple. ;) static assert(is(void)==true); (a)

Re: transversal sum

2014-11-06 Thread Artur Skawina via Digitalmars-d-learn
On 11/06/14 18:32, bearophile via Digitalmars-d-learn wrote: > Marc Schütz: > >> We'd need something taking and returning a RoR that "mirrors" them >> diagonally. Then we could simply apply `map!(r => r.sum)` on the result. > > A simple solution is to create a row of values, and then sum them co

Re: `shared Mutex`?

2014-12-28 Thread Artur Skawina via Digitalmars-d-learn
On 12/28/14 10:24, Aiden via Digitalmars-d-learn wrote: > Is `shared` in a workable state? No. > Shouldn't Mutex, Condition, etc be shared since they are basically only ever > useful when used in multiple threads? Yes, but there are so many problems with 'shared' that using it that way (even on

Re: Copy only frame pointer between objects of nested struct

2015-01-06 Thread Artur Skawina via Digitalmars-d-learn
On 01/06/15 23:14, Peter Alexander via Digitalmars-d-learn wrote: > auto foo(T)(T a) { > T b; // Error: cannot access frame pointer of main.X > b.data[] = 1; > return b; > } > > void main() { > struct X { > this(int) {} > int[4096] data; > } > foo(X());

Re: reinterpret array

2015-01-13 Thread Artur Skawina via Digitalmars-d-learn
On 01/13/15 21:52, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: > On Tuesday, 13 January 2015 at 20:11:45 UTC, anonymous wrote: >> On Tuesday, 13 January 2015 at 20:00:57 UTC, Dominikus Dittes Scherkl wrote: >>> So if I have a function that allowes to do this: >>> >>> uint a; >>> a.bit[1

Re: static class vs. static struct

2015-01-27 Thread Artur Skawina via Digitalmars-d-learn
On 01/27/15 10:40, Daniel Kozak via Digitalmars-d-learn wrote: > On Tuesday, 27 January 2015 at 09:36:49 UTC, Daniel Kozak wrote: >> On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: >>> For several times I've met struct(or static struct) usage in Phobos for >>> singleton pattern impleme

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Artur Skawina via Digitalmars-d-learn
On 01/28/15 10:44, zhmt via Digitalmars-d-learn wrote: > I have a struct created by thrift: > > struct Card { > long id; > string pwd; > long agentId; > bool valid; > long rmb; > long createDate; > long soldDate; > long chargeDate; > > mixin TStructHelpers!([ > TFieldMeta(`i

Re: Labels in struct

2015-01-31 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/15 17:04, tcak via Digitalmars-d-learn wrote: > > struct CommunicationMessage{ [...] > content: > } > > > Example I defined something like above. I am using it as a base structure, > and don't know how long the content of message will be. But I know that it > will be at the end. I cou

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 19:27, Kagamin via Digitalmars-d-learn wrote: > On Friday, 6 March 2015 at 16:39:56 UTC, Ali Çehreli wrote: >> mixin (makePairInitValueDefinitions()); > > Oh, so that's how you do static foreach. No, you implement it using CTFE magic, and then that code becomes: import std.typetup

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 22:29, Artur Skawina wrote: > No, you implement it using CTFE magic, and then that code becomes: >#foreach (N; 0..PairInitValues.length/2) { > enum PairInitValue(T:PairInitValues[$N*2]) = PairInitValues[$N*2+1]; >} > Seriously though, avoid using `.stringof` when generat

Re: enum and static if

2015-03-11 Thread Artur Skawina via Digitalmars-d-learn
On 03/11/15 15:41, ketmar via Digitalmars-d-learn wrote: > On Wed, 11 Mar 2015 14:36:07 +, wobbles wrote: > >> On Wednesday, 11 March 2015 at 14:34:32 UTC, ketmar wrote: >>> On Wed, 11 Mar 2015 13:48:45 +, Namespace wrote: >>> This code does not work: enum Test { >

Re: Creating a microcontroller startup file

2015-04-09 Thread Artur Skawina via Digitalmars-d-learn
On 04/08/15 18:10, Jens Bauer via Digitalmars-d-learn wrote: > On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: >> On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: >> >> enum weak = gcc.attribute.attribute("weak"); >> enum isrDefault = gcc.attribute.attribute("alias", "defaultHand

Re: Make a type tuple from an array

2015-04-11 Thread Artur Skawina via Digitalmars-d-learn
On 04/10/15 17:36, John Colvin via Digitalmars-d-learn wrote: > On Friday, 10 April 2015 at 15:13:54 UTC, Marc Schütz wrote: >> Is there a way to turn an array (known at compile time) into a TypeTuple? > For input ranges in general: > > import std.range : isInputRange; > > template TypeTupleOf(

Re: Reducing source code: weak+alias values in array

2015-04-29 Thread Artur Skawina via Digitalmars-d-learn
On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: > I was wondering if there's a way to reduce my bulky startup files a bit. > > If using the GNU Assembler (GAS), then one can reduce the code using a macro > like this: > > > /* The EXC macro makes a weak+alias for the > * symbol 'va

Re: Reducing source code: weak+alias values in array

2015-05-01 Thread Artur Skawina via Digitalmars-d-learn
On 05/01/15 22:29, Jens Bauer via Digitalmars-d-learn wrote: > On Wednesday, 29 April 2015 at 13:58:14 UTC, Artur Skawina wrote: >> On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: >>> I was wondering if there's a way to reduce my bulky startup files a bit. > {snip} > >> Just create a

Re: Reducing source code: weak+alias values in array

2015-05-02 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/15 05:28, Jens Bauer via Digitalmars-d-learn wrote: > On Saturday, 2 May 2015 at 03:21:38 UTC, Jens Bauer wrote: >> For some reason, my build time has increased dramatically... >> >> Building with 1 vector takes 0.6 seconds. >> Building with 2 vector takes 0.7 seconds. >> Building with 4 v

Re: Multiple template alias parameters

2015-05-08 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: > The problem occurs when I want to register multiple modules to scan for > functions. The grammar does not allow this syntax: > > ``` > template (alias Modules ...) { > ... > ``` The grammar allows omitting the 'alias' keyword. art

Re: Multiple template alias parameters

2015-05-09 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 23:56, Brian Schott via Digitalmars-d-learn wrote: > On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote: >> On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: >>> The problem occurs when I want to register multiple modules to scan for >>> functions. The grammar does

Re: Destructured Tuple Assignment

2015-05-15 Thread Artur Skawina via Digitalmars-d-learn
import std.algorithm; template magicassign(A...) { void magicassign(B)(B b) @property { foreach(I, ref a; A) static if (!is(typeof(A[I]):typeof(null))) a = b[I]; } } template let(string D) { mixin({ enum sdsl = D.findSplit

Re: Call-ie return on behalf of caller?

2015-06-04 Thread Artur Skawina via Digitalmars-d-learn
On 06/04/15 00:37, Tofu Ninja via Digitalmars-d-learn wrote: > Is there a way other than exceptions for a called function to force the > caller to return? > > Specifically, I know the return type of the caller(its always bool) and under > certain circumstances I would like the caller to just giv

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Artur Skawina via Digitalmars-d-learn
On 07/03/15 12:52, Laeeth Isharc via Digitalmars-d-learn wrote: > I have an array of structs eg > > struct PriceBar > { > DateTime date; > double open; > double high; > double low; > double close; > } > > (which fields are present in this particular struct will depend on template > arg

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread Artur Skawina via Digitalmars-d-learn
On 07/27/15 14:03, Vlad Leberstein via Digitalmars-d-learn wrote: > Hi! My use case requires interaction with C API which in turn implies storing > object instance reference as void *. I'm using gdc 4.9.2 and everything > worked fine with "object -> void * -> object" conversion, but "object -> vo

Re: __traits(allMembers) and aliases

2015-08-26 Thread Artur Skawina via Digitalmars-d-learn
On 08/26/15 14:42, Mike Parker via Digitalmars-d-learn wrote: > This doesn't help me distinguish aliased function names. [...] > I don't want to put any restrictions on what the user can have in the > module/class/struct that contains the function pointer. It's just that > aliased function name

Re: Why is the constructor of B called?

2015-09-24 Thread Artur Skawina via Digitalmars-d-learn
On 09/24/15 13:26, Marc Schütz via Digitalmars-d-learn wrote: > On Thursday, 24 September 2015 at 01:01:09 UTC, Nicholas Wilson wrote: >> On Wednesday, 23 September 2015 at 21:25:15 UTC, tcak wrote: >>> On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23 Sept

Re: What is the corect behavour for lazy in foreach variadic template

2015-09-25 Thread Artur Skawina via Digitalmars-d-learn
On 09/25/15 17:47, Ali Çehreli via Digitalmars-d-learn wrote: > Perhaps we need an enhancement that either works in your original code [...] His original code does work (`foreach` evaluates `args[N]` and assigns the result to `arg`). If he wanted to delay the evaluation, he would have written it

Re: Get template parameter value

2015-09-29 Thread Artur Skawina via Digitalmars-d-learn
On 09/29/15 12:13, rumbu via Digitalmars-d-learn wrote: > On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: >> On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: >>> Welcome to the weird and wonderful work of >>> http://dlang.org/expression.html#IsExpression >> >> No, u

Re: Check template parameter whether it has "length"

2015-10-08 Thread Artur Skawina via Digitalmars-d-learn
On 10/08/15 11:29, tcak via Digitalmars-d-learn wrote: > I am "trying" to write a function that takes an array of items, and returns > the length of longest item. > > [code] > size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, > "length" ) ) > { > return 0; // not impl

Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 15:51, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 14:27:39 Igor Shirkalin via Digitalmars-d-learn > wrote: >> I think you may write it (I mean actual D) with using some >> template like this: >> >> auto array = static_array!uint(1, 2, 3, 4) >> >> Cou

Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 17:30, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 17:03:32 Artur Skawina via Digitalmars-d-learn > wrote: >> On 11/25/16 15:51, Jonathan M Davis via Digitalmars-d-learn wrote: >>> On Friday, November 25, 2016 14:27:

Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 18:33, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 18:20:11 Artur Skawina via Digitalmars-d-learn > wrote: >> On 11/25/16 17:30, Jonathan M Davis via Digitalmars-d-learn wrote: >>> On Friday, November 25, 2016 17:03:32 Artur Ska