31
Implementation Details / Re: CTC (partial, full, none)
« Last post by lerno on February 12, 2019, 12:47:59 AM »Of what use is CTC partial? I don't really see it.
Foo& foo();
Foo* foo2();
void bar(Foo& f);
void bar2(Foo* f);
Foo *f1 = foo(); // Non null to nullable ok
Foo &f2 = foo2(); // Nullable to non null not allowed
Foo *f = foo2();
assert(f);
Foo &f2 = f;
Foo *f = foo2();
Foo &f2 = f ? f : foo();
Foo &f = foo2() ?: foo();
Foo* f = foo2();
return f.a; // warn, f may be null.
Foo *f = foo2();
return f.a @(notnull);
int a = void; // a not initialized, warning if used before later assignment.
free(p);
p = void;
return p; // error: use of an invalid value.
int a; // a initialized to 0, as if it was static.
int a = 10; // a initialized to 10
int a = uninitialized; // a not initialized, warning if used before later assignment.
int a = ---;
int a = *;
int a = ?;
public macro foreach(thelist, @body(Element *) ) {
Element* iname = thelist.first;
while (iname != nil) {
@body(iname);
iname = iname.next;
}
}
public macro foreach(thelist, @body(typeof(thelist.first)) ) {
typeof(thelist.first) iname = thelist.first;
while (iname != nil) {
@body(iname);
iname = iname.next;
}
}
foreach(list, Element *i) { // <- Note type declaration!
i.print();
}
public macro foreach(thelist, @body($@thelist.first) ) {
$@thelist.first iname = thelist.first;
while (iname != nil) {
@body(iname);
iname = iname.next;
}
}
public macro foreach(thelist, @body($element_type) ) {
$element_type iname = thelist.first;
while (iname != nil) {
@body(iname);
iname = iname.next;
}
}
public macro foreach(thelist, iname) {
@require {
thelist.first;
thelist.first.next == thelist.first;
}
Element* iname = thelist.first;
while (iname != nil) {
// macro body should be here, How to specify?
iname = iname.next;
}
}
public macro foreach(thelist, iname) {
@require {
thelist.first;
thelist.first.next == thelist.first;
}
typeof(iname.first) iname = thelist.first;
while (iname != nil) {
// macro body should be here, How to specify?
iname = iname.next;
}
}
public macro foreach(thelist, iname) {
@require {
thelist.first;
thelist.first.next == thelist.first;
}
$element_type = typeof(iname.first); // Not visible after compilation
$element_type iname = thelist.first;
while (iname != nil) {
// macro body should be here, How to specify?
iname = iname.next;
}
}
type List contract {
self.first;
self.first.next == self.first;
}
public macro foreach(@List thelist, iname) {
$element_type = typeof(iname.first); // Not visible after compilation
$element_type iname = thelist.first;
while (iname != nil) {
// macro body should be here, How to specify?
iname = iname.next;
}
}