[Issue 8106] func.stringof with default args

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 13 15:48:01 PDT 2012


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



--- Comment #5 from Manu <turkeyman at gmail.com> 2012-06-13 15:50:11 PDT ---
(In reply to comment #4)
> Can you post an example of why you need this? Perhaps there's another way.

It's difficult for me to extract a concrete example (a very large context, in
work code), but essentially I'm creating functions/methods that match (wrap)
user declared function pointers, which include default args in the
declarations. The default args need to propagate to the magic wrappers.

There is no mechanism to copy a parameter list from one function type to
another (with names + default args), nor are there traits to get the argument
names, or the default arg expression, so I can only construct declarations for
mixins by parsing that string.


An alternative approach I can use (prefer) is to invert the problem, allowing
the user to define function prototypes (rather than function pointers), and
then procedurally produce the function body. Although this conflicts with the
limitation I posted in bug 8108, where you can't forward declare/prototype a
function in a module/class, and then define it later in the same scope.
The prototype would be declared by a user, and a later mixin would scan for
prototypes and produce the function bodies within the same module.

// user declares:
void Function(int x = 10); // note: default args are still important

// and using magic, mixin:
void Function(int x)
{
  // generated body..
}

-- 
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