On Wed, Sep 17, 2014 at 10:57 PM, Stephen R. van den Berg <s...@cuci.nl> wrote: > Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum wrote: >>What if b is declared as "string|String.Buffer"? Is it "obvious" what >>should happen then? > > string|String.Buffer is a union type, so using it in conjunction with > an `= lfun should result in an error reported to the programmer.
class Foo { mixed `=(Foo other) {...} } class Bar { } int main() { string|Foo|Bar x=Foo(); x = Bar(); } So this code would be illegal, then? What if x were declared as "mixed", or maybe as "object" instead of "string|Foo|Bar"? Personally, I'm strongly against the idea of an assignment-replacement operator. Assignment to a member is governed by the container (with `[]= or `->=), and assignment to a simple name should just overwrite it. Anything else would be extremely confusing. (Side point: With the actual `=() line commented out, the above code compiles and runs with no problems. But changing the declaration from "string|Foo|Bar" to just "Foo|Bar" results in a compilation error, "syntax error, unexpected TOK_IDENTIFIER, expecting TOK_LEX_EOF or ';'". It seems the parser's unable to handle piped declarations that don't start with a recognized name. I'd never noticed that till now, which I guess means it's not much of a limitation!) ChrisA