Re: Question regarding readf

2019-04-23 Thread diniz via Digitalmars-d-learn
Le 23/04/2019 à 00:23, Adam D. Ruppe via Digitalmars-d-learn a écrit : (my personal feeling though is readf is just a pile of confusion and should almost never be used. I hate that it is introduced so early in most tutorials... I'd rather have it in an appendix for special cases only rather

Re: I really don't understand DUB

2019-04-15 Thread diniz via Digitalmars-d-learn
Le 15/04/2019 à 09:57, Paolo Invernizzi via Digitalmars-d-learn a écrit : I guess that just killing all that educated dub guess will turn dub into a much easier tool to grasp. Probably. I had similar issues as well. Now I keep all as simple and explicit as possible. (And it works, at least in

Re: Subtyping of an enum

2019-04-15 Thread diniz via Digitalmars-d-learn
Le 15/04/2019 à 10:39, Anton Fediushin via Digitalmars-d-learn a écrit : This seems to work just fine for assigning and comparisons but passing Enum as a function argument does not work: ``` void fun(Enum e) {} fun(Enum.foo); --- Error: function fun(Enum e) is not callable using argument types

Re: Transparent cast from class to member pointer?

2019-04-15 Thread diniz via Digitalmars-d-learn
Le 15/04/2019 à 08:30, Robert M. Münch via Digitalmars-d-learn a écrit : The C side requires that *impl is the 1st member in the struct/class whereever it is stored. Hence, the wrapping in a struct and not directly putting it into a D class. All right! Did not think at this usage case,

Re: Transparent cast from class to member pointer?

2019-04-14 Thread diniz via Digitalmars-d-learn
Le 14/04/2019 à 20:03, Robert M. Münch via Digitalmars-d-learn a écrit : struct IM; struct C {  IM *impl; }; int cInit(C* self); class I { C handler; this(){cInit();} } Is there a simple way that I can use handler without the address-of operator and automatically get *impl?

Re: Iterate/sort associative array by value?

2019-04-08 Thread diniz via Digitalmars-d-learn
Le 07/04/2019 à 19:16, Seb via Digitalmars-d-learn a écrit : Then you can do: --- ["a": 1].byPair.array.sort!((a, b) => a.value < a.value).release.each!writeln; --- You'll have a sorted array with key and value props. That's what I would do: just operating on an array of {k,v} pairs. --

Re: == comparison of string literals, and their usage

2019-04-07 Thread diniz via Digitalmars-d-learn
Le 07/04/2019 à 14:23, bauss via Digitalmars-d-learn a écrit : On Saturday, 6 April 2019 at 19:47:14 UTC, lithium iodate wrote: On Saturday, 6 April 2019 at 15:35:22 UTC, diniz wrote: So, I still could store and use and compare string pointers myself [1], and get valid results, meaning:

Re: == comparison of string literals, and their usage

2019-04-06 Thread diniz via Digitalmars-d-learn
Le 06/04/2019 à 21:47, lithium iodate via Digitalmars-d-learn a écrit : On Saturday, 6 April 2019 at 15:35:22 UTC, diniz wrote: So, I still could store and use and compare string pointers myself [1], and get valid results, meaning: pointer equality implies (literal) string equality. Or am I

Re: == comparison of string literals, and their usage

2019-04-06 Thread diniz via Digitalmars-d-learn
Le 06/04/2019 à 16:07, AltFunction1 via Digitalmars-d-learn a écrit : On Friday, 5 April 2019 at 14:49:50 UTC, diniz wrote: Hello, Since literal strings are interned (and immutable), can I count on the fact that they are compared (==) by pointer? No. "==" performs a full array comparison

== comparison of string literals, and their usage

2019-04-05 Thread diniz via Digitalmars-d-learn
Hello, Since literal strings are interned (and immutable), can I count on the fact that they are compared (==) by pointer? Context: The use case is a custom lexer for a custom language. I initially wanted to represent lexeme classes by a big enum 'LexClass'. However, this makes me write 3