Menu
Home
Create new Paste
Log in
with (wrap.x = args.length) do
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
/* Written in the D programming language. * Copyright: 2012 Nick Treleaven <nick dot treleaven at btinternet com> * License: Boost Software License, Version 1.0. See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. */ // tested with dmd 2.060 import std.stdio; import std.typecons; struct Wrap { template opDispatch(string name) { struct WrapAssign { auto opAssign(T)(T x) { return Tuple!(T, name)(x); } } enum opDispatch = WrapAssign(); } } Wrap wrap; void main(string[] args) { auto count = args.length + 2; with (wrap.x = count) do { x.writeln; } while (--x != 0); static assert(!__traits(compiles, {x.writeln;})); with (wrap.y = count ^^ 3) if (y > 1) y.writeln; static assert(!__traits(compiles, {y = 1;})); }
Result:
Success
/
Return code: 0
/
Compilation time:
0.483
seconds
/
Run time:
0.001
seconds
Disassembly
Application output:
3
2
1
27
Username
Message
Add comment
Paste info
Author:
Guest
Views:
77
Private:
no
Expires:
Never
Uploaded:
07.12.12 15:19
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.060
Pointer size:
m64
Actions
Download
Fork
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason