On 2019-04-14 20:01:27 +, diniz said:
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
Hello! I am currently trying to add a custom `toString` method to
an enum so that:
1. Enum members would still have numeric values and can be easily
compared (things like `enum a { foo = "FOO", bar = "BAR”}` won't
do, I want `a.foo < a.bar)`)
2. More custom methods can be implemented in the
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
to an enum so that:
1. Enum members would still have numeric values and can be
easily compared (things like `enum a { foo = "FOO", bar =
"BAR”}` won't do, I want
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
Several remarks... First of all, strings can be compared
(alphabetically) as well as integers, e.g.
assert("foo" > "bar")
Perhaps not your use case, but worth
On Sunday, 14 April 2019 at 20:51:10 UTC, Andre Pany wrote:
On Sunday, 14 April 2019 at 19:46:41 UTC, Ron Tarrant wrote:
[...]
You are totally right, it should be more intuitive how to use
dub.
As far as I know if you do not specify in dub.json/dub.sdl what
type of package you have
On 04/14/2019 11:03 AM, Robert M. Münch wrote:
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?
Something like:
class I {
On Monday, 15 April 2019 at 10:00:36 UTC, Alex wrote:
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
[snip]
Otherwise, you could alwas define fun as
´´´
void fun(Enum.internal e) {}
´´´
but I assume, you want to avoid especially this.
In favor of my first proposition,
On Monday, 15 April 2019 at 10:06:30 UTC, XavierAP wrote:
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
Several remarks... First of all, strings can be compared
(alphabetically) as well as integers, e.g.
On Sun, 2019-04-14 at 20:51 +, Andre Pany via Digitalmars-d-learn
wrote:
[…]
> As far as I know if you do not specify in dub.json/dub.sdl what
> type of package you have (executable/library) dub make a guess.
> Is there an app.d it will default the targetType "executable", if
> not it will
On Monday, 15 April 2019 at 10:15:50 UTC, Anton Fediushin wrote:
On Monday, 15 April 2019 at 10:00:36 UTC, Alex wrote:
Enum.internal is private to make it inaccessible from any other
place. All I want is a way to have an enum that I could extend
with my own methods.
Something to make the
On Monday, 15 April 2019 at 13:38:33 UTC, Anton Fediushin wrote:
This does work unless I want to use it like this:
```
fun(Enum.foo);
---
Error: function fun(Enum e) is not callable using argument
types (internal)
cannot pass argument foo of type internal to parameter Enum e
```
This is
On Monday, 15 April 2019 at 15:07:10 UTC, Robert M. Münch wrote:
On 2019-04-15 08:19:57 +, Ali ‡ehreli
Bingo, I didn't know that I can do an 'alias this' using a
function and not only a type... pretty cool. So, with several
of these I can setup implicit conversions to different types.
On Monday, 15 April 2019 at 12:25:38 UTC, XavierAP wrote:
On Monday, 15 April 2019 at 10:34:42 UTC, Anton Fediushin wrote:
On Monday, 15 April 2019 at 10:06:30 UTC, XavierAP wrote:
[snip]
Isn't this how subtyping works for integers and other types?
For example, you have subtyped an integer
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
On Monday, 15 April 2019 at 10:34:42 UTC, Anton Fediushin wrote:
On Monday, 15 April 2019 at 10:06:30 UTC, XavierAP wrote:
You have defined your sub-typing the opposite way that you
wanted it to work: every `Enum` is an `internal`, but the
other way around an `internal` may not work as an
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,
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
to an enum so that:
1. Enum members would still have numeric values and can be
easily compared (things like `enum a { foo = "FOO", bar =
"BAR”}` won't do, I want
On 2019-04-15 08:19:57 +, Ali ehreli said:
'alias this' can do that:
Hi, I had the suspicion already...
struct IM;
struct C {
IM *impl;
};
int cInit(C* self) {
return 0;
}
class I {
C handler;
this(){cInit();}
C* ptr() { // <== ADDED
return
On Monday, 15 April 2019 at 10:34:42 UTC, Anton Fediushin wrote:
The problem here is that I want to keep methods that are
related to an enum inside of this enum for purely aesthetic and
organizational purposes.
...
These global functions pollute global namespace.
If you have defined
On Monday, 15 April 2019 at 10:45:26 UTC, Alex wrote:
On Monday, 15 April 2019 at 10:15:50 UTC, Anton Fediushin wrote:
On Monday, 15 April 2019 at 10:00:36 UTC, Alex wrote:
[snip]
This would:
´´´
struct Enum {
private {
enum internal {
foo,
bar
}
internal m_enum;
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
On Monday, 15 April 2019 at 12:38:59 UTC, XavierAP wrote:
More generally you insist on modules and namespaces to be
different concepts, which they are (pointlessly) for C++, but
not for D (purposely).
Here I should say packages instead of modules... but the general
argument stays.
Anyway
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
to an enum so that:
1. Enum members would still have numeric values and can be
easily compared (things like `enum a { foo = "FOO", bar =
"BAR”}` won't do, I want
On Sunday, 14 April 2019 at 20:51:10 UTC, Andre Pany wrote:
To solve your specify the targetType explicitly in your dub.sdl
file.
https://dub.pm/package-format-json.html#target-types
Kind regards
Andre
Thanks, Andre. Yeah, I did sort that out. My dilemma ATM is why
I'm (seemingly
On Monday, 15 April 2019 at 14:11:05 UTC, diniz wrote:
Le 15/04/2019 à 10:39, Anton Fediushin via Digitalmars-d-learn
a écrit :
[snip]
I don't understand why you just don't call fun with an Enum
(struct) param, since that is how fun is defined. This works by
me (see call in main):
struct
On Monday, 15 April 2019 at 20:36:09 UTC, Anton Fediushin wrote:
On Monday, 15 April 2019 at 14:20:57 UTC, Alex wrote:
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin
wrote:
Hello! I am currently trying to add a custom `toString`
method to an enum so that:
1. Enum members would still
On Monday, 15 April 2019 at 14:20:57 UTC, Alex wrote:
On Monday, 15 April 2019 at 08:39:24 UTC, Anton Fediushin wrote:
Hello! I am currently trying to add a custom `toString` method
to an enum so that:
1. Enum members would still have numeric values and can be
easily compared (things like
On Monday, 15 April 2019 at 05:20:37 UTC, Ali Çehreli wrote:
BaseClassesTuple and friends:
https://dlang.org/phobos/std_traits.html
And the implementation of that is the `is` expression
https://dlang.org/spec/expression.html#IsExpression
specifically, with the `super` keyword.
static if
On Monday, 15 April 2019 at 22:45:59 UTC, Adam D. Ruppe wrote:
On Monday, 15 April 2019 at 05:20:37 UTC, Ali Çehreli wrote:
BaseClassesTuple and friends:
https://dlang.org/phobos/std_traits.html
And the implementation of that is the `is` expression
29 matches
Mail list logo