On Monday, 26 February 2018 at 21:07:52 UTC, Meta wrote:
This is possible in the language today using the implicit class
construction feature of runtime variadic arrays:
class VArray
{
Variant[] va;
this(T...)(T ts) { foreach(t; ts) { va ~= Variant(t); } }
}
void test(VArray ta...)
On Monday, 26 February 2018 at 21:36:49 UTC, ketmar wrote:
aliak wrote:
It makes libraries *much* more intuitive and expressive (C++
just got it wrong by choosing the wrong default). If you allow
library authors to opt in instead of opt out then it becomes a
conscious decision for one.
On Monday, 26 February 2018 at 19:32:44 UTC, ketmar wrote:
WebFreak001 wrote:
Now before you would have only been able to do this:
---
Nullable!Foo a;
foo(a, Nullable!int(5));
---
but now you should also be able to do:
---
Nullable!Foo x = null;
Nullable!Foo y = 5;
foo(null, 5);
please
On Monday, 26 February 2018 at 23:33:48 UTC, H. S. Teoh wrote:
Not really a big deal (and auto kind of ruins it) but it would
make stuff consistent between user types and built in ones.
Not sure what you mean here. In a user type, if opBinary!"/"
returns an int, then you still have the same
On Tuesday, 27 February 2018 at 13:36:30 UTC, ketmar wrote:
aliak wrote:
On Monday, 26 February 2018 at 21:34:21 UTC, ketmar wrote:
aliak wrote:
And if that's also a no no, how about char -> int. Or int ->
float? Is ok?
no, it is not ok. it was a mistake. it is now too late to fix
it,
aliak wrote:
On Monday, 26 February 2018 at 21:34:21 UTC, ketmar wrote:
aliak wrote:
And if that's also a no no, how about char -> int. Or int -> float? Is
ok?
no, it is not ok. it was a mistake. it is now too late to fix it, but we
can avoid doing more of the same kind.
Oops, yeah, ok,
On Monday, 26 February 2018 at 19:25:06 UTC, WebFreak001 wrote:
hi, I had an idea from using some C# which I think would be
really cool in D. Basically allow modifying implicit
construction of a type. Right now we only have struct
opAssign/constructor implicit conversion, but this addition
On Monday, 26 February 2018 at 21:36:49 UTC, ketmar wrote:
aliak wrote:
It makes libraries *much* more intuitive and expressive (C++
just got it wrong by choosing the wrong default). If you allow
library authors to opt in instead of opt out then it becomes a
conscious decision for one.
On Monday, 26 February 2018 at 21:34:21 UTC, ketmar wrote:
aliak wrote:
And if that's also a no no, how about char -> int. Or int ->
float? Is ok?
no, it is not ok. it was a mistake. it is now too late to fix
it, but we can avoid doing more of the same kind.
Oops, yeah, ok, D char ...
On Mon, Feb 26, 2018 at 09:45:03PM +, TheFlyingFiddle via Digitalmars-d
wrote:
> On Monday, 26 February 2018 at 21:30:09 UTC, aliak wrote:
> > On Monday, 26 February 2018 at 19:32:44 UTC, ketmar wrote:
> > > WebFreak001 wrote:
> > And if that's also a no no, how about char -> int. Or int ->
On Monday, 26 February 2018 at 21:30:09 UTC, aliak wrote:
On Monday, 26 February 2018 at 19:32:44 UTC, ketmar wrote:
WebFreak001 wrote:
And if that's also a no no, how about char -> int. Or int ->
float? Is ok?
Maybe there're some valid arguments, to disallow it
*completely* though?
aliak wrote:
It makes libraries *much* more intuitive and expressive (C++ just got it
wrong by choosing the wrong default). If you allow library authors to opt
in instead of opt out then it becomes a conscious decision for one.
library authors can create overloads for various argument types.
On Monday, 26 February 2018 at 19:32:44 UTC, ketmar wrote:
WebFreak001 wrote:
Now before you would have only been able to do this:
---
Nullable!Foo a;
foo(a, Nullable!int(5));
---
but now you should also be able to do:
---
Nullable!Foo x = null;
Nullable!Foo y = 5;
foo(null, 5);
please
aliak wrote:
And if that's also a no no, how about char -> int. Or int -> float? Is ok?
no, it is not ok. it was a mistake. it is now too late to fix it, but we
can avoid doing more of the same kind.
On Monday, 26 February 2018 at 19:25:06 UTC, WebFreak001 wrote:
Now this would be really useful for Variant:
---
struct Variant {
this(U)(U value) @implicit { ... }
}
void bar(Variant x, Variant y) {}
Variant[] myObjects = [1, 2, "abc", new Node()];
Variant a = 4;
bar(4, "asdf");
---
WebFreak001 wrote:
Now before you would have only been able to do this:
---
Nullable!Foo a;
foo(a, Nullable!int(5));
---
but now you should also be able to do:
---
Nullable!Foo x = null;
Nullable!Foo y = 5;
foo(null, 5);
please no. such unobvious type conversions goes out of control
hi, I had an idea from using some C# which I think would be
really cool in D. Basically allow modifying implicit construction
of a type. Right now we only have struct opAssign/constructor
implicit conversion, but this addition would also add it to
classes and make it even more convenient.
17 matches
Mail list logo