Re: Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 02:18:28 UTC, Kayomn wrote: On Friday, 6 April 2018 at 01:22:42 UTC, Kayomn wrote: On Friday, 6 April 2018 at 01:14:37 UTC, ketmar wrote: Kayomn wrote: [...] it is already done for you, free of charge. class Node {} class RootNode : Node {}

Re: Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 01:22:42 UTC, Kayomn wrote: On Friday, 6 April 2018 at 01:14:37 UTC, ketmar wrote: Kayomn wrote: [...] it is already done for you, free of charge. class Node {} class RootNode : Node {} class SpriteNode : Node {} void main () {

Re: Game and GC

2018-04-05 Thread Leonardo via Digitalmars-d-learn
On Friday, 23 February 2018 at 03:25:33 UTC, Norm wrote: On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying

Re: Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 01:14:37 UTC, ketmar wrote: Kayomn wrote: [...] it is already done for you, free of charge. class Node {} class RootNode : Node {} class SpriteNode : Node {} void main () { auto nodeId1 = typeid(Node);

Re: Compile-time variables

2018-04-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 06, 2018 00:35:39 Kayomn via Digitalmars-d-learn wrote: > On Friday, 6 April 2018 at 00:21:54 UTC, H. S. Teoh wrote: > > On Thu, Apr 05, 2018 at 11:53:00PM +, Kayomn via > > Digitalmars-d-learn wrote: [...] > > > >> [...] > > > > [...] > > > >> [...] > > > > `lastID`, as

Re: Compile-time variables

2018-04-05 Thread ketmar via Digitalmars-d-learn
Kayomn wrote: I'll give a better example of what it is I'm trying to do. These are node types. Their contents are not important in this explanation, only that they operate as a tree structure. class Node; class RootNode : Node; class SpriteNode : Node; The result of getNodeID on a

Re: Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
I'll give a better example of what it is I'm trying to do. These are node types. Their contents are not important in this explanation, only that they operate as a tree structure. class Node; class RootNode : Node; class SpriteNode : Node; The result of getNodeID on a specific type is

Re: Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
On Friday, 6 April 2018 at 00:21:54 UTC, H. S. Teoh wrote: On Thu, Apr 05, 2018 at 11:53:00PM +, Kayomn via Digitalmars-d-learn wrote: [...] [...] [...] [...] `lastID`, as declared above, are runtime variables. The 'static' in this case just means it's thread-local, rather than

Re: Compile-time variables

2018-04-05 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Apr 05, 2018 at 11:53:00PM +, Kayomn via Digitalmars-d-learn wrote: [...] > --- > alias NodeTypeID = uint; > > enum NodeTypeID getNodeID() { > static NodeTypeID lastID = 0; > > return lastID++; >

Compile-time variables

2018-04-05 Thread Kayomn via Digitalmars-d-learn
Hi, I've got a scene graph which contains multiple inheriting types. As such, I've been tagging them with a type enum for whenever I need to do things such as loading a structure from binary. Up until now I've been using an enum that looks like this:

Re: Construct immutable member in derived class

2018-04-05 Thread Alex via Digitalmars-d-learn
On Thursday, 5 April 2018 at 19:31:39 UTC, Jonathan M Davis wrote: And you can't abstract whether a member variable is marked with immutable or not. That's part of the variable. Declaring an immutable instance of an object would then treat the member variable in immutable for that instance, so

Re: Issues using the in-line assembler

2018-04-05 Thread solidstate1991 via Digitalmars-d-learn
Seems I found a better solution hidden in the docs: @nogc protected int[2] transformFunc(int[2] xy){ version(X86){ asm @nogc{ naked; mov EBX, this; movdXMM1, sX[EBX]; pslldq XMM1, 4; movss XMM1, sY[EBX];

Re: Issues using the in-line assembler

2018-04-05 Thread solidstate1991 via Digitalmars-d-learn
On Thursday, 5 April 2018 at 04:48:02 UTC, Basile B. wrote: The "this" seems to be in R11, so you have to apply the asm syntax for accessing the members using .offsetof.[R11], example: ``` class Foo { double a = 123456; extern(D) double foo() { asm {

Re: Idiomatic error handling for ranges

2018-04-05 Thread rumbu via Digitalmars-d-learn
On Thursday, 5 April 2018 at 17:36:56 UTC, Seb wrote: On Thursday, 5 April 2018 at 17:06:04 UTC, rumbu wrote: Is there a standard way to handle errors in a chain of range transformations? [...] Are you aware of ifThrown? https://dlang.org/phobos/std_exception.html#ifThrown It's not

Re: Construct immutable member in derived class

2018-04-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 05, 2018 13:36:07 Alex via Digitalmars-d-learn wrote: > On Wednesday, 4 April 2018 at 21:49:08 UTC, Timoses wrote: > > "[...] the construction of the base class can be independent > > from the derived one." > > > > Hm, the points 7 and 8 don't clearly state what you wrote. > >

Re: [OT] Re: merkle reverse

2018-04-05 Thread aerto via Digitalmars-d-learn
On Thursday, 5 April 2018 at 14:58:21 UTC, Andy Smith wrote: On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote: This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format

Re: Construct immutable member in derived class

2018-04-05 Thread Timoses via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 22:47:07 UTC, Jonathan M Davis wrote: Because doing that basically makes it impossible to guarantee that the type system isn't violated. Once an immutable variable has been initialized, its value must _never_ change. It must be initalized exactly once, and the

Re: Idiomatic error handling for ranges

2018-04-05 Thread Seb via Digitalmars-d-learn
On Thursday, 5 April 2018 at 17:06:04 UTC, rumbu wrote: Is there a standard way to handle errors in a chain of range transformations? [...] Are you aware of ifThrown? https://dlang.org/phobos/std_exception.html#ifThrown It's not perfect, but imho a nice start and one of the places where

Re: Idiomatic error handling for ranges

2018-04-05 Thread Timoses via Digitalmars-d-learn
On Thursday, 5 April 2018 at 17:06:04 UTC, rumbu wrote: Is there a standard way to handle errors in a chain of range transformations? Let's say I want to read some comma separated numbers from a file. auto myArray = file.byLine().splitter().map!(to!int).array(); Now, besides fatal errors

Idiomatic error handling for ranges

2018-04-05 Thread rumbu via Digitalmars-d-learn
Is there a standard way to handle errors in a chain of range transformations? Let's say I want to read some comma separated numbers from a file. auto myArray = file.byLine().splitter().map!(to!int).array(); Now, besides fatal errors (like I/O), let's suppose I want to handle some errors in a

[OT] Re: merkle reverse

2018-04-05 Thread Andy Smith via Digitalmars-d-learn
On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote: This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a ?? i try it using string

Re: merkle reverse

2018-04-05 Thread SimonN via Digitalmars-d-learn
On Thursday, 5 April 2018 at 09:49:58 UTC, Seb wrote: Strings are bi-directional ranges, but they aren't random-access nor have a length chunks requires hasSlicing + hasLength: Okay, thanks for the great references. chunks/slide certainly need the length to decide which, and how many,

Re: Construct immutable member in derived class

2018-04-05 Thread Alex via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 21:49:08 UTC, Timoses wrote: "[...] the construction of the base class can be independent from the derived one." Hm, the points 7 and 8 don't clearly state what you wrote. Yes :) But it somehow does make sense.. Still I wonder why that is so. Let's say you

Re: merkle reverse

2018-04-05 Thread Seb via Digitalmars-d-learn
On Thursday, 5 April 2018 at 09:24:31 UTC, SimonN wrote: On Thursday, 5 April 2018 at 09:07:52 UTC, Seb wrote: FYI: The problem isn't chunks, but that strings aren't bi-directional ranges (hello ugly auto-decoding!). "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b".byCodeUnit

Re: merkle reverse

2018-04-05 Thread SimonN via Digitalmars-d-learn
On Thursday, 5 April 2018 at 09:07:52 UTC, Seb wrote: FYI: The problem isn't chunks, but that strings aren't bi-directional ranges (hello ugly auto-decoding!). "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b".byCodeUnit Thanks! Very appropriate because it's all hex digits

Re: merkle reverse

2018-04-05 Thread Seb via Digitalmars-d-learn
On Thursday, 5 April 2018 at 08:57:11 UTC, SimonN wrote: On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote: This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format

Re: merkle reverse

2018-04-05 Thread drug via Digitalmars-d-learn
05.04.2018 11:57, SimonN пишет: Here's one solution with std.range.chunks. A small downside is that it needs the array allocation in the middle because chunks cannot offer the bi-directional range necessary for retro.     import std.range;     import std.algorithm;     void main()    

Re: merkle reverse

2018-04-05 Thread SimonN via Digitalmars-d-learn
On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote: This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a ?? i try it using string

merkle reverse

2018-04-05 Thread aerto via Digitalmars-d-learn
This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a ?? i try it using string merkle =