Last active
November 22, 2020 19:54
-
-
Save thedeemon/f1bb8c5d5c76f1b232dbe050b274407d to your computer and use it in GitHub Desktop.
A test of @LiVe in D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dmd -preview=dip1021 liev.d | |
import std.stdio; | |
struct S { string name; } | |
@live void use(scope const S* p) { // ok | |
writeln(p.name); | |
} | |
void release(S *p) { } // consumes the ownership | |
// how do I make this work? | |
@live auto longer(scope const S* a, scope const S* b) { | |
if (a.name.length > b.name.length) | |
return a; | |
else | |
return b; | |
} | |
@live void foo() | |
{ | |
auto a = new S("aaa"); | |
auto b = new S("bb"); | |
auto c = longer(a,b); // if you comment out this line, it compiles | |
release(a); | |
release(b); | |
} | |
void main() { | |
writeln("hi!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment