Re: Generically call a function on Variant's payload?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 9:08:39 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/19/2018 10:23 PM, Jonathan M Davis wrote: > > On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via > > > > Digitalmars-d-learn wrote: > >> Maybe something involving

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Paul Backus via Digitalmars-d-learn
On Monday, 20 August 2018 at 00:27:04 UTC, Nick Sabalausky (Abscissa) wrote: Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/19/2018 10:23 PM, Jonathan M Davis wrote: On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: Maybe something involving using Variant.coerce to convert the payload to a single common type? Not sure how I would do that though. You could

D need an ORM library!

2018-08-19 Thread binghoo dang via Digitalmars-d-learn
hi, I thinks D need an ORM library for Sqlite/Mysql/PostgreSQL, entity currently support all the three targets, but entity's API is too complex and cumbersome for using. Is there a more light-weight and simpler implementation like ActiveAndroid ? Thanks! --- Binghoo Dang

Re: InputRange help: (1) repeated dtor calls and (2) managing resources needing free()

2018-08-19 Thread James Blachly via Digitalmars-d-learn
On Monday, 13 August 2018 at 13:20:25 UTC, Seb wrote: BTW it's very uncommon for empty to do work, it's much more common to do such lazy initialization in `.front`. Thanks Seb, that entire reply is a huge help. By lazy initialization in `.front`, do you mean that I should find a way for

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 6:33:06 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/19/2018 08:27 PM, Nick Sabalausky (Abscissa) wrote: > > Suppose I've wrapped a Variant in a struct/class which ensures the > > Variant *only* ever contains types which satisfy a particular

Re: Are properties mature enough?

2018-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 19, 2018 12:32:17 PM MDT QueenSvetlana via Digitalmars-d- learn wrote: > In the D Style Guide, it says: > > Properties > https://dlang.org/dstyle.html#properties > > Functions should be property functions whenever appropriate. In > particular, getters and setters should generally

Re: Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 08/19/2018 08:27 PM, Nick Sabalausky (Abscissa) wrote: Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a function (ex:

Generically call a function on Variant's payload?

2018-08-19 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
Suppose I've wrapped a Variant in a struct/class which ensures the Variant *only* ever contains types which satisfy a particular constraint (for example: isInputRange, or hasLength, etc...). Is there a way to call a function (ex: popFront) on the Variant, *without* knowing ahead of time all

Re: Using .length returns incorrect number of elements

2018-08-19 Thread Simen Kjærås via Digitalmars-d-learn
On Sunday, 19 August 2018 at 16:03:06 UTC, QueenSvetlana wrote: On Sunday, 19 August 2018 at 15:53:25 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:49:18 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:44:07 UTC, QueenSvetlana wrote: [...] auto appendNumber =

Re: Are properties mature enough?

2018-08-19 Thread ag0aep6g via Digitalmars-d-learn
On 08/19/2018 08:55 PM, Neia Neutuladh wrote: You *could* add @property to the next and seed functions. That forces people to use them as fields. It doesn't.

Re: Are properties mature enough?

2018-08-19 Thread Neia Neutuladh via Digitalmars-d-learn
On Sunday, 19 August 2018 at 18:32:17 UTC, QueenSvetlana wrote: In the D Style Guide, it says: Properties https://dlang.org/dstyle.html#properties Functions should be property functions whenever appropriate. In particular, getters and setters should generally be avoided in favor of property

Are properties mature enough?

2018-08-19 Thread QueenSvetlana via Digitalmars-d-learn
In the D Style Guide, it says: Properties https://dlang.org/dstyle.html#properties Functions should be property functions whenever appropriate. In particular, getters and setters should generally be avoided in favor of property functions. And in general, whereas functions should be verbs,

Re: Using .length returns incorrect number of elements

2018-08-19 Thread Chris M. via Digitalmars-d-learn
On Sunday, 19 August 2018 at 16:03:06 UTC, QueenSvetlana wrote: On Sunday, 19 August 2018 at 15:53:25 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:49:18 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:44:07 UTC, QueenSvetlana wrote: [...] auto appendNumber =

Re: Using .length returns incorrect number of elements

2018-08-19 Thread QueenSvetlana via Digitalmars-d-learn
On Sunday, 19 August 2018 at 15:53:25 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:49:18 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:44:07 UTC, QueenSvetlana wrote: [...] auto appendNumber = appender(arrayofNumbers); This returns a separate object. You probably meant to put

Re: Using .length returns incorrect number of elements

2018-08-19 Thread Chris M. via Digitalmars-d-learn
On Sunday, 19 August 2018 at 15:49:18 UTC, Chris M. wrote: On Sunday, 19 August 2018 at 15:44:07 UTC, QueenSvetlana wrote: [...] auto appendNumber = appender(arrayofNumbers); This returns a separate object. You probably meant to put this for the last line writeln(appendNumber.length);

Re: Using .length returns incorrect number of elements

2018-08-19 Thread Chris M. via Digitalmars-d-learn
On Sunday, 19 August 2018 at 15:44:07 UTC, QueenSvetlana wrote: When using the .length property of a dynamic array why does it return the incorrect number of elements after I use the appender? import std.stdio; import std.array : appender; void main() { //declaring a dynamic array

Using .length returns incorrect number of elements

2018-08-19 Thread QueenSvetlana via Digitalmars-d-learn
When using the .length property of a dynamic array why does it return the incorrect number of elements after I use the appender? import std.stdio; import std.array : appender; void main() { //declaring a dynamic array int [] arrayofNumbers; //append an element using the ~= syntax

Re: Static initialization of static arrays is weird

2018-08-19 Thread Dennis via Digitalmars-d-learn
On Sunday, 19 August 2018 at 12:10:08 UTC, kinke wrote: I think the spec is pretty clear; the elements of the right-hand-side initializer array are interpreted as per-element initializer, i.e., `result[0] = 2, result[1] = 1` (rest: default-init). I can't find where in the spec it says that

Re: Static initialization of static arrays is weird

2018-08-19 Thread kinke via Digitalmars-d-learn
On Sunday, 19 August 2018 at 11:20:41 UTC, Dennis wrote: I have a two dimensional static array in a game board struct and want to explicitly set the default value for each cell. Now typing the whole 9x9 array out would be cumbersome and I can't change the default constructor of a struct, so I

Static initialization of static arrays is weird

2018-08-19 Thread Dennis via Digitalmars-d-learn
I have a two dimensional static array in a game board struct and want to explicitly set the default value for each cell. Now typing the whole 9x9 array out would be cumbersome and I can't change the default constructor of a struct, so I played around with initializers and found some... strange

Re: How to phrase RIP addressing in assembly under Linux AMD64

2018-08-19 Thread Sean O'Connor via Digitalmars-d-learn
Okay, I see. I'll try with a shared library. I only have 3 or 4 algorithms that don't auto-vectorize well with modern compilers and have to be written by hand. Patreon have that terrible catch 22 tax form that stopped me writing for US magazines, rather unfortunate.

how to build DSFMLC ?

2018-08-19 Thread Flaze07 via Digitalmars-d-learn
I keep having the same problem with building DSFMLC https://ibb.co/edRStK

Re: How to phrase RIP addressing in assembly under Linux AMD64

2018-08-19 Thread Basile B. via Digitalmars-d-learn
On Sunday, 19 August 2018 at 07:18:20 UTC, Sean O'Connor wrote: How to I phrase RIP addressing in assembly under Linux AMD64 in D. I can't seem to figure it out. Normally I do something like: movq rax,rndphi[rip] Where rndphi is a label pointing to data. I know I have change movq to mov in

How to phrase RIP addressing in assembly under Linux AMD64

2018-08-19 Thread Sean O'Connor via Digitalmars-d-learn
How to I phrase RIP addressing in assembly under Linux AMD64 in D. I can't seem to figure it out. Normally I do something like: movq rax,rndphi[rip] Where rndphi is a label pointing to data. I know I have change movq to mov in D and hope the operation works on all 64 bits. If for some