Mixin Expressions, can't evalutate string variable

Andrej Mitrovic andrej.mitrovich at gmail.com
Fri Aug 6 19:04:07 PDT 2010

Damn regexe(s|n).

I almost never need them, but when I do, I have to spend an hour trying to
remember the syntax (+ I'm really used to doing regexes in Python and then
there's the whole "regex objects in lang x work different than in lang y"
thing). But I digress..

I think a better way is to pass strings which will be used to name the
variables to be constructed and initialized (+ return an error when there's
too few). And then at least you'll know there are some new local variables
at your disposal by looking at the call. That way we solve both problems.

On Sat, Aug 7, 2010 at 12:12 AM, Andrej Mitrovic <andrej.mitrovich at gmail.com
> wrote:

> Slightly OT: I've noticed you're often missing the word "know" in your
> posts (e.g. "I don't what", that should be "I don't know what"). Is
> something filtering your posts? :)
> And yeah, I've noticed your other thread with the argument names. With a
> little bit of regex I could easily extract the variable names. I think this
> template could be useful in cases when you just want to try out a function
> which happens to writes some state in the parameters that are passed to it
> (out/ref params), without having to inspect the function signature and
> declare the proper variable types. Unfortunately there's no way to pass auto
> variables as parameters, but that's more of a Python territory, I guess.
> On the other hand, the template introduces new identifiers silently into
> the calling site (you can't see it in the code), so it's not all that
> practical I guess, not to mention a little dangerous. :p
> On Fri, Aug 6, 2010 at 10:22 PM, Philippe Sigaud <
> philippe.sigaud at gmail.com> wrote:
>> Andrej:
>>> It was just an exercise for fun but it's cool that things like this are
>>> possible in D. It would be nice if I could get the actual names of the
>>> parameters the function takes + the clear name of the function itself, that
>>> way I'd actually get back variables "ftc, fta, ftm" back)
>> There, found it again, while answering another thread:
>> int foo(int i, double d) { return 0;}
>> writeln(typeof(&foo).stringof); // "int function(int i, double d)" <--
>> Look Ma, arguments names!
>> But it's a quirk of .stringof, I'm not sure it's a good idea to rely on it
>> too much.
>> from there, using compile-time search in a string, you can extract the
>> arguments (those are between ( and ) )
>> -> "int i, double d"
>> and from there, extracting i and d.
>> I don't what will happen for overloaded functions, methods names,
>> constructors, ...
>> Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100807/9e9176f0/attachment-0001.html>

More information about the Digitalmars-d mailing list