[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2013-11-26 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=3075


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||govell...@gmail.com


--- Comment #24 from yebblies yebbl...@gmail.com 2013-11-27 15:33:25 EST ---
*** Issue 7708 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2013-11-26 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=3075


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||timon.g...@gmx.ch


--- Comment #25 from yebblies yebbl...@gmail.com 2013-11-27 17:59:35 EST ---
*** Issue 7221 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2013-11-26 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=3075



--- Comment #26 from yebblies yebbl...@gmail.com 2013-11-27 18:00:41 EST ---
*** Issue 7219 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2013-11-09 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=3075


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #23 from yebblies yebbl...@gmail.com 2013-11-10 02:05:52 EST ---
*** Issue 7725 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2011-06-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075


yebblies yebbl...@gmail.com changed:

   What|Removed |Added

 CC||eatingstap...@gmail.com


--- Comment #22 from yebblies yebbl...@gmail.com 2011-06-15 23:36:12 PDT ---
*** Issue 5471 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2009-07-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075





--- Comment #18 from Sobirari Muhomori ma...@pochta.ru  2009-07-13 01:42:00 
PDT ---
Now I see how this can be connected with delegate casting, but what this has to
do with overloading?
So now contravariance is not supported at all for overloading? Only exact
match? I don't see how this can conflict with function casting. Aren't the
contextes different? In the context of overloading check for exact match, in
the context of overload resolution check for implicit cast as for any other
type. They hardly can clash, only if the compiler is written so that they
clash.
I suppose no algorithm for implicit function casting was written. It seems it
only needs to be written, though I'm not familiar with compiler intrinsics, so
I can lose some important details :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2009-07-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075


Steven Schveighoffer schvei...@yahoo.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||schvei...@yahoo.com
 Blocks|2267|
 Resolution|INVALID |
   Severity|normal  |enhancement




--- Comment #9 from Steven Schveighoffer schvei...@yahoo.com  2009-07-08 
10:36:32 PDT ---
I'll chime in a bit on this.

What the original poster is looking for is not all-encompasing contravariance,
it's a specific case.  He is saying that a delegate that takes a const type is
a subtype of the delegate that takes a mutable (or immutable) version of that
type, similar to how mutable and immutable are subtypes of const.

Similarly, it should be possible to implicitly convert a delegate that takes an
object to a delegate that takes, for instance, a Stream, since Stream is
implicitly convertable to object, and can viably be passed to that function.

(In reply to comment #4)
 The actual rule for matching a delegate against a type is that the delegate is
 covariant with the type. The return type is checked for covariance, and things
 like a pure function is considered covariant with an impure one. This works
 exactly the same as overriding a virtual function with a covariant one.

You're missing the issue here, a delegate today is not variant at all, you
can't implicitly cast a delegate to another type in any case that I know of.

 What you're asking for with the const parameters is contravariance.
 Contravariant parameters are a good idea until overloading is considered.

how do you overload delegates?  As far as I know, a delegate is a pointer to a
single overload, not an overload group (though the latter would sometimes be
nice).

 If
 you have two functions, one with a const parameter and the other mutable, 
 which
 one overrides the base virtual function? You could say overriding is based on 
 a
 'best match', but things are complex enough without throwing that into the 
 mix.

Yes, contravariance in other cases makes things difficult unless you specify
the direction of the variance.  For example in C#4, you can do contravariance
and covariance with generics (check out bearophile's example:
http://codepad.org/kQgbwAqJ)

But in delegates, we are talking about casting a concretely defined type. 
Implicit casting to what should be valid should be allowed.

In fact, I don't even think this works today:

class C{
void foo(string s);
void foo(const(char)[] s);
}

C c = new c;
void delegate(const(char)[]) foo2 = c.foo; // error, didn't select the right
overload

// or it's the other way around, can't remember

Similarly, implicit covariant delegates should also be allowed.  That is,

class C {
C foo();
}

C c = new C;
object delegate() foo2 = c.foo;

(In reply to comment #1)
 Is it tango2 blocker? There is a tracker for tango2 blockers - bug 2267.

Not that I'm aware of, I removed it as a blocker.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2009-07-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075





--- Comment #3 from Walter Bright bugzi...@digitalmars.com  2009-07-03 
00:51:57 PDT ---
const, yes, but not immutable as that would require that mutable be implicitly
convertible to immutable, which cannot be.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2009-07-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075


david dav...@126.com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|INVALID |




--- Comment #5 from david dav...@126.com  2009-07-03 07:56:21 PDT ---
(In reply to comment #3)
 const, yes, but not immutable as that would require that mutable be implicitly
 convertible to immutable, which cannot be.

It's not implicit cast. But a special case for function/delegate parameters.

Any qualifier for parameters or for the function is a restriction for the
function. So you can still treat them as a special case of mutable version just
they don't change anything even they are allowed to change the parameter.


This is another testcase. 
void foo(void delegate(void[]) dg);

void test()
{
void func(invariant(void)[] t)
{
}

foo(func);
}

test.func won't change paramter t. So this func as a delegate is perfectly safe
to hold the prototype which has no restrictions on parameters.

It's not casting invariant(void)[] to void[]. It's implicitly casting from
void delegate(invariant(void)[]) to void delegate(void[]).

Furthermore, it's pretty ugly to write:
void foo(void delegate(void[]) dg);

void test()
{
void func(invariant(void)[] t)
{
}

foo(cast(void delegate(void[]))func);
}

I don't think it is an invalid bug. But you can mark it as WONTFIX.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3075] void delegate(const(void)[]) should be implicitly convertable to void delegate(void[])

2009-07-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3075


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com




--- Comment #2 from Walter Bright bugzi...@digitalmars.com  2009-07-02 
19:27:02 PDT ---
A test case:

void foo(void delegate(void[]) dg);

void test()
{
void func(const(void)[] t)
{
}

foo(func);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---