The type of (s << "answer:") is 'string buffer', so it calls the parent method for ((s << "answer:") << 42). The types of expressions are resolved at compile time, not at run time.
About 'local'
struct strbuf: local string buffer
...
end
is somewhat equivalent to:
struct strbuf
super: local string buffer
...
end
hence the 'local'
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>> The type of (s << "answer:") is 'string buffer', so it calls the parent method for ((s << "answer:") << 42). The types of expressions are resolved at compile time, not at run time.
Yes, that is what I meant when I said that zinc doesn't upcast. :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
consider this code:
import "text/string-buffer"
struct strbuf: local string buffer // why is local required ?
...
end
public equ @shl (s: strbuf, c: int) = str append(s,c)
def s = new strbuf
s << "answer:" << 42 // calls the parent's method, not child's 'str append'
Is this a bug or a feature ? Shouldn't the child's method have precedence.
The type of (s << "answer:") is 'string buffer', so it calls the parent method for ((s << "answer:") << 42). The types of expressions are resolved at compile time, not at run time.
About 'local'
struct strbuf: local string buffer
...
end
is somewhat equivalent to:
struct strbuf
super: local string buffer
...
end
hence the 'local'
>> The type of (s << "answer:") is 'string buffer', so it calls the parent method for ((s << "answer:") << 42). The types of expressions are resolved at compile time, not at run time.
Yes, that is what I meant when I said that zinc doesn't upcast. :)