[Issue 5710] cannot use delegates as parameters to non-global template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 6 16:32:04 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5710



--- Comment #5 from David Simcha <dsimcha at yahoo.com> 2011-03-06 16:29:07 PST ---
(In reply to comment #3)
> (In reply to comment #2)
> > So is this an WONTFIX, then?
> 
> Unless there's an epiphany somewhere, yes. How would you suggest two hidden
> context pointers be handled? Is it clear that two context pointers are required
> (at least for this example)?

Honestly, I don't know enough about the details of how DMD works under the hood
to come up with a good answer, but my completely naive answer would be to pass
the delegate context pointer in as a hidden argument between the explicit
arguments and the hidden class instance pointer.  The class instance pointer is
still passed last (no special casing) and the delegate context pointer lives on
the stack somewhere as a regular stack variable and gets passed in when needed.

> 
> > Unfortunately it severely hurts my
> > std.parallelism design in some use cases, and a workaround for it would be a
> > significant PITA to implement, make the API uglier, and possibly be
> > inefficient.
> 
> I don't know enough about your design to offer help with that. Perhaps instead
> of an alias parameter, make fun explicitly a delegate?

This would be the workaround, but I probably won't implement it because:

1.  If I still keep alias parameters, I'll have to have two implementations of
map(), reduce() and friends.  This is ugly from both an API and an
implementation perspective.

2.  Delegates can't be inlined. Aliases can.

3.  Delegates can only be instantiations of templates.  Aliases can be
templates.  This means that a nested template function would have to be
explicitly instantiated.  This is ugly.

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


More information about the Digitalmars-d-bugs mailing list