On Saturday, 4 August 2012 at 03:07:21 UTC, Era Scarecrow wrote:
Then doesn't it seem like we're missing a potentially important
piece of the puzzle for mixins and templates? very likely my
modified template will include you including the same variable
twice, but if someone gets lazy then it
On Saturday, 4 August 2012 at 03:07:21 UTC, Era Scarecrow wrote:
This can't work in general. What should such a function
return? The fully qualified name, I.e. including packages and
modules? What is if the referred to entity is a nested
function/local variable? What is if it is defined in a
On Saturday, 4 August 2012 at 08:53:20 UTC, David Nadlinger wrote:
How do you determine what the »local level« is? A string
mixin isn't something you can »call«, just a compile-time
constant string, which can be »evaluated« in a completely
different place than it can be constructed. Maybe some
On Saturday, 4 August 2012 at 10:08:34 UTC, Era Scarecrow wrote:
---
mixin template BitfieldsOn(alias target, …) if
(isIntegral!(typeof(target))) {
mixin({
string code;
// Generate code using target as identifier.
return code;
}());
}
mixin BitfieldsOn!(foo, …);
On Sat, Aug 4, 2012 at 10:53 AM, David Nadlinger s...@klickverbot.at wrote:
example:
---
mixin template BitfieldsOn(alias target, …) if
(isIntegral!(typeof(target))) {
mixin({
string code;
// Generate code using target as identifier.
return code;
}());
}
On Sat, Aug 4, 2012 at 1:23 PM, David Nadlinger s...@klickverbot.at wrote:
On Saturday, 4 August 2012 at 10:08:34 UTC, Era Scarecrow wrote:
---
mixin template BitfieldsOn(alias target, …) if
(isIntegral!(typeof(target))) {
mixin({
string code;
// Generate code using target
On 08/04/2012 01:35 PM, Philippe Sigaud wrote:
On Sat, Aug 4, 2012 at 10:53 AM, David Nadlingers...@klickverbot.at wrote:
example:
---
mixin template BitfieldsOn(alias target,…) if
(isIntegral!(typeof(target))) {
mixin({
string code;
// Generate code using target as
On Sat, Aug 4, 2012 at 3:04 PM, Timon Gehr timon.g...@gmx.ch wrote:
This should be
explained somewhere, as it's a tool anyone using templates to do
metaprogramming should be aware of.
http://d.puremagic.com/issues/show_bug.cgi?id=7653
Yes. There is a workaround, but we lose the elegance of
On Saturday, 4 August 2012 at 11:23:07 UTC, David Nadlinger wrote:
I'm not sure what you mean with »[…] the only acceptable
input is a string; Since strings won't hold the type
information...« – the input to BitfieldsOn is _not_ a
string, it is an alias. The trick is that you can refer to it
Le 4 août 2012 00:50, David Nadlinger s...@klickverbot.at a écrit :
On Friday, 3 August 2012 at 22:23:23 UTC, Era Scarecrow wrote:
Seems like an ugly hack though (to get this done). Why not have another
method of fullpathStringof or something similar? Then again if this is one
of the few
On Saturday, August 04, 2012 09:57:36 Philippe Sigaud wrote:
For std.reflection that Andrei proposed 2 weeks ago, I feel the internal
code will contain many __traits() calls. Nothing to be done about it.
__traits is *the* way compile-time introspection is done in D.
That and std.traits.
Era Scarecrow rtcv...@yahoo.com
Then doesn't it seem like we're missing a potentially important piece of
the puzzle for mixins and templates? very likely my modified template will
include you including the same variable twice, but if someone gets lazy
then it may not work.
On Saturday, 4 August 2012 at 07:57:46 UTC, Philippe Sigaud wrote:
FWIW, I agree with David that using .stringof is a last resort
and can lead to nasty bugs. .stringof has a sometime incoherent
behavior (I remember it showing the entire code inside a
delegate literal)
But then, the code
On Saturday, 4 August 2012 at 08:06:31 UTC, Jonathan M Davis
wrote:
On Saturday, August 04, 2012 09:57:36 Philippe Sigaud wrote:
For std.reflection that Andrei proposed 2 weeks ago, I feel
the internal
code will contain many __traits() calls. Nothing to be done
about it.
__traits is *the* way
On Saturday, 4 August 2012 at 07:57:46 UTC, Philippe Sigaud wrote:
It uses __traits(parent, ) and __traits(qualifier, ), which are
much more
'modern' and well-behaved.
An example of what I mean: Try this with your CurryTemplate from
dranges:
---
import dranges.templates;
template Foo(A,
On Sat, Aug 4, 2012 at 10:25 AM, David Nadlinger s...@klickverbot.at wrote:
An example of what I mean: Try this with your CurryTemplate from dranges:
---
import dranges.templates;
template Foo(A, B) {
pragma(msg, A.stringof, , B.stringof);
}
alias CurryTemplate!Foo FooCurried;
On Saturday, 4 August 2012 at 11:29:36 UTC, Philippe Sigaud wrote:
Oh, I completely forgot this. Nice code, if I may say so myself
:)
Huh? It's broken, precisely because of the use of
__traits(identifier, …) in combination with string mixins. The
example doesn't compile.
David
On Sat, Aug 4, 2012 at 1:35 PM, David Nadlinger s...@klickverbot.at wrote:
On Saturday, 4 August 2012 at 11:29:36 UTC, Philippe Sigaud wrote:
Oh, I completely forgot this. Nice code, if I may say so myself :)
Huh? It's broken, precisely because of the use of __traits(identifier, …) in
This is moved/copied from the D.learning group. I need opinions
on the matter, and thoughts perhaps from Walter or Andrei.
Here are the highlights
---
While working on bitfields code I've found a unique scenario that
poses some annoyances when generating the code.
template XYZ(alias x) {
While working on bitfields code I've found a unique scenario
that poses some annoyances when generating the code.
template XYZ(alias x) {
enum XYZ = x.stringof ~ =100;;
}
struct I { int i;}
I i_num;
int n;
mixin(XYZ!(i_num.i)); //cannot find variable i
mixin(XYZ!(n));
the mixins
On Friday, 3 August 2012 at 21:02:22 UTC, Era Scarecrow wrote:
Now, how do I get the template's stringof to print out
'i_num.i' and not 'i'?
You don't. Using .stringof in conjunction with string mixins is
The Wrong Thing (tm) in virtually all cases.
What do you want to achieve? Why can't
On Friday, 3 August 2012 at 21:19:08 UTC, David Nadlinger wrote:
On Friday, 3 August 2012 at 21:02:22 UTC, Era Scarecrow wrote:
Now, how do I get the template's stringof to print out
'i_num.i' and not 'i'?
You don't. Using .stringof in conjunction with string mixins is
The Wrong Thing (tm)
On 8/3/12, Era Scarecrow rtcv...@yahoo.com wrote:
Now, how do I get the template's stringof to print out 'i_num.i'
and not 'i'?
Courtesy of Philippe Sigaud, slightly edited to my style:
/**
Return the fully qualified name of a symbol.
Implemented by Philippe Sigaud in the D Templates
On 8/4/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
On 8/3/12, Era Scarecrow rtcv...@yahoo.com wrote:
Now, how do I get the template's stringof to print out 'i_num.i'
and not 'i'?
snip
Ahh crap, it doesn't return the *instance* name. Sorry!! Maybe there
can be a fix though, I'll
On Friday, 3 August 2012 at 22:18:25 UTC, Andrej Mitrovic wrote:
On 8/4/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
On 8/3/12, Era Scarecrow rtcv...@yahoo.com wrote:
Now, how do I get the template's stringof to print out
'i_num.i'
and not 'i'?
snip
Ahh crap, it doesn't return
On 8/4/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
On 8/3/12, Era Scarecrow rtcv...@yahoo.com wrote:
Now, how do I get the template's stringof to print out 'i_num.i'
and not 'i'?
Courtesy of Philippe Sigaud, slightly edited to my style:
In fact, this should really be put into
On Friday, 3 August 2012 at 21:33:35 UTC, Era Scarecrow wrote:
Because a string doesn't hold it's type information for size
checking.
int = 4 bytes or 32 bits
string =
Just emit the check into the code you generate.
It also checks for unsuitable types like structs and floats;
On Friday, 3 August 2012 at 22:23:23 UTC, Era Scarecrow wrote:
Seems like an ugly hack though (to get this done). Why not
have another method of fullpathStringof or something similar?
Then again if this is one of the few cases that could benefit
from it, then maybe we should make it ugly so
28 matches
Mail list logo