s that are syntactically correct. The arguments
cannot be statements or declarations. "
When there's a closing ;, it is a mixin statement.
void F(){}
pragma(msg, __traits( compiles, mixin("F();") ) );//false
Oh, now thats explains. I thought that a "mixin statement"
tements or declarations. "
When there's a closing ;, it is a mixin statement.
void F(){}
pragma(msg, __traits( compiles, mixin("F();") ) );//false
The semicolon there indicates it is a complete statement that
does nothing, and that's no error.
so why this line resolves to false?
void F(){}
pragma(msg, __traits( compiles, mixin("F();") ) );//false
On Wednesday, 25 October 2017 at 19:25:01 UTC, Adam D. Ruppe
wrote:
On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote:
Maybe i´m tired already, but whats wrong here:
pragma(msg, __traits( compiles, mixin("int x") ) );
You are missing a ;
The mixin must compile as a
On Wednesday, 25 October 2017 at 19:21:27 UTC, SrMordred wrote:
mixin( "T();" ); Error: `structliteral` has no effect in
expression `T()`
The semicolon there indicates it is a complete statement that
does nothing, and that's no error.
If there's no ;, it is just an expression that must be so
On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote:
Maybe i´m tired already, but whats wrong here:
pragma(msg, __traits( compiles, mixin("int x") ) );
//output: false
Or the original case I found:
struct T{}
pragma(msg, __traits( compiles, T() ) ); //true
pragma(msg
On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote:
Maybe i´m tired already, but whats wrong here:
pragma(msg, __traits( compiles, mixin("int x") ) );
You are missing a ;
The mixin must compile as a full thing in context. Variable
declarations need the ; to be complete.
Maybe i´m tired already, but whats wrong here:
pragma(msg, __traits( compiles, mixin("int x") ) );
//output: false
On Tuesday, 5 March 2013 at 12:58:57 UTC, Timon Gehr wrote:
Compiles as expected with DMD 2.060. It is probably a
regression.
Ah you're right, also with 2.061. I'll file.
On 03/05/2013 08:53 AM, cal wrote:
I'm confused about this:
import std.conv;
void main()
{
enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto a = new "~s~";}")); // line 1
mixin("auto a = "~s~";");
On Tuesday, 5 March 2013 at 08:14:58 UTC, simendsjo wrote:
Hmm.. And this also works:
enum c = __traits(compiles, mixin("{auto a = new 1;}"));
Something to do with CTFE combined with mixins?
But it gets this right, in that c is false. I had thought that by
wrapping the declaration
On 3/5/13, cal wrote:
> So why does this work:
>
> import std.conv;
>
> void main()
> {
> enum s = "`1`.to!int;";
> enum c = __traits(compiles, mixin("{auto x = "~s~";}")); //
> true
> }
That's a function literal, i.e. an expression.
On Tuesday, 5 March 2013 at 08:04:12 UTC, Andrej Mitrovic wrote:
On Tuesday, 5 March 2013 at 07:53:15 UTC, cal wrote:
I'm confused about this:
import std.conv;
void main()
{
enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto a = new
"~s~";}&q
t std.conv;
void main()
{
enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto x = "~s~";}")); //
true
}
Hmm.. And this also works:
enum c = __traits(compiles, mixin("{auto a = new 1;}"));
Something to do with CTFE combined with mixins?
t;";
enum c = __traits(compiles, mixin("{auto x = "~s~";}")); //
true
}
On Tuesday, 5 March 2013 at 07:53:15 UTC, cal wrote:
I'm confused about this:
import std.conv;
void main()
{
enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto a = new
"~s~";}")); // line 1
mixin("auto a = "~s~";&quo
I'm confused about this:
import std.conv;
void main()
{
enum s = "`1`.to!int;";
enum c = __traits(compiles, mixin("{auto a = new "~s~";}"));
// line 1
mixin("auto a = "~s~";");
/
On 2010-07-05 10.03, Jonathan M Davis wrote:
Is there a way to use string mixins with is(typeof(X)) and/or __traits(compiles,
X)? As far as I can tell, if I do either of the following
is(typeof(mixin(X)))
__traits(compiles, mixin(X))
it does not mixin the string and test that for compilation
Is there a way to use string mixins with is(typeof(X)) and/or
__traits(compiles,
X)? As far as I can tell, if I do either of the following
is(typeof(mixin(X)))
__traits(compiles, mixin(X))
it does not mixin the string and test that for compilation but rather tests
whether the mixin
19 matches
Mail list logo