Re: Functor alias this

2018-06-05 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 06:25:49 UTC, DaggetJones wrote: Hi, I'm wondering how I should approach supplying functions/delegates around in D. I have option of using classes where the function exists inside the class and to provide different functionality different classes are created. Altern

Functor alias this

2018-06-05 Thread DaggetJones via Digitalmars-d-learn
Hi, I'm wondering how I should approach supplying functions/delegates around in D. I have option of using classes where the function exists inside the class and to provide different functionality different classes are created. Alternatively I could just pass the function directly around without

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 22:08:32 Stefan Koch via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer > > wrote: > > No, it's definitely a bug. main is not being evaluated at > > compile time. The real result of this function should be a > > compile-time err

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 18:00:05 UTC, Steven Schveighoffer wrote: No, it's definitely a bug. main is not being evaluated at compile time. The real result of this function should be a compile-time error -- __ctfe is a *runtime* value that is always defined based on whether you are __ctfe or

Re: Orange serializer/deserializer

2018-06-05 Thread InfiniteDimensional via Digitalmars-d-learn
I'm also having some issue now when I changed a type from using a class to using it's base interface Unhandled exception: orange.serialization.SerializationException.SerializationException The object of the static type "const(ItemInterface)" have a different runtime type (Item) and therefore ne

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/18 12:10 PM, Stefan Koch wrote: This is not bug just not very intuitive. Since you are declaring a static array the value of n needs to known at compiletime. so it'll  try to evaluate n at an compile-time context in which n is 1. however when code-generation for the function is done __c

Re: Orange serializer/deserializer

2018-06-05 Thread InfiniteDimensional via Digitalmars-d-learn
On Saturday, 2 June 2018 at 20:11:17 UTC, Jacob Carlborg wrote: On 2018-06-02 03:30, IntegratedDimensions wrote: How can I modify the pre serialization and post serialization values? I need to transform some variables that are stored but I would like to do this easily "inline"(would be cool to

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 13:27:35 UTC, Steven Schveighoffer wrote: On 6/5/18 6:40 AM, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() {     immutable n = __ctfe ? 1 : 2;     int[n] a;     assert(a.length == n); // fails, wat } That's gotta be a bug - th

Re: determining if array element is null

2018-06-05 Thread Alex via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 14:52:28 UTC, Timoses wrote: Does `int[4] nums = void` work? Work for what? If you avoid initialization, then the variable(s) are not initialized. https://dlang.org/spec/declaration.html#void_init However, an int is not nullable and always contains a value.

Re: determining if array element is null

2018-06-05 Thread Timoses via Digitalmars-d-learn
On Saturday, 2 June 2018 at 18:10:38 UTC, eastanon wrote: Does D array implementation support an array of null values? int a[4] = null; But I ran into a type error while checking if a[i] is null foreach(i; 0..3){ if(i == null){ writeln("it is null"); } } } How do you set fixed size a

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/18 6:40 AM, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() {     immutable n = __ctfe ? 1 : 2;     int[n] a;     assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at compile time' error. T

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 05, 2018 11:18:05 Gopan via Digitalmars-d-learn wrote: > On Tuesday, 5 June 2018 at 10:40:20 UTC, Simen Kjærås wrote: > > On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: > >> void main() > >> { > >> > >> immutable n = __ctfe ? 1 : 2; > >> int[n] a; > >> assert(a.l

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Gopan via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 10:40:20 UTC, Simen Kjærås wrote: On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() { immutable n = __ctfe ? 1 : 2; int[n] a; assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 5 June 2018 at 09:36:22 UTC, Gopan wrote: void main() { immutable n = __ctfe ? 1 : 2; int[n] a; assert(a.length == n); // fails, wat } That's gotta be a bug - that should give a 'variable n cannot be read at compile time' error. The fact that n is immutable shouldn't b

Re: Confusion/trying to understand CTFE keywords

2018-06-05 Thread Gopan via Digitalmars-d-learn
On Sunday, 3 June 2018 at 21:32:06 UTC, gdelazzari wrote: Couldn't a keyword like "ctfe" (just making it up right now) exist? So that, when seeing something like ctfe myNumber = 5; ctfe if (myNumber + 2 == 7) { // ... } one could immediately understand that the code is executed/evaluated a

Re: Line endings when redirecting output to file on windows.

2018-06-05 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 4 June 2018 at 15:31:04 UTC, Steven Schveighoffer wrote: Windows C library has this bizarro mode for FILE * called "text" mode, which is the default. In this mode, it scans all output, and anywhere it sees a '\n', it replaces it with "\r\n". Thanks, Steven.