On Sunday 07 May 2017 12:11:06 code dz wrote: > > sounds good , but i think it add some complexity to the code > readability, because the name (add) already indicates the operation , > so why ['+'] , maybe operator instead of method should be fine ! . > just thought > The method names can be choosen freely: " complexty = object real,imm: flo64; method add(const a,b: complexty): complexty ['+']; method sub(const a,b: complexty): complexty ['-']; method mulblabla(const a,b: complexty): complexty ['*']; method tostring8(const source: complexty): string8 [':=']; method tostring16(const source: complexty): string16 [':=']; end;
complex2ty object(complexty) scale: flo64; method addscaled(const a,b: complexty): complexty ['+']; method subscaled(const a,b: complexty): complexty ['-']; end; " so "operator" instead of an attachment would not work. " complexty = object real,imm: flo64; operator add(const a,b: complexty): complexty; operator sub(const a,b: complexty): complexty; operator mulblabla(const a,b: complexty): complexty; operator tostring8(const source: complexty): string8; operator tostring16(const source: complexty): string16; end; complex2ty object(complexty) scale: flo64; operator addscaled(const a,b: complexty): complexty; operator subscaled(const a,b: complexty): complexty; end; " Also " method add(const a,b: complexty): complexty ['+']; " can be used as ordinary object method so I don't think it should be named "operator". " method complexty.add(const a,b: complexty): complexty; begin result.real:= a.real + b.real; result.imm:= a.imm + b.imm; end; var a,b,c: complexty; [...] a:= b + c; a:= add(b,c); " Martin ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk