digitalmars.D.learn - free function on arrays & language operations
- spir (12/12) Dec 07 2010 Hello again,
- bearophile (4/5) Dec 07 2010 You may find some trick to do something like that, but it's not how D is...
Hello again, I started to be found of defining types which basically are arrays with fre= e functions, instead of creating a struct or class with methods. Not only w= e still have pseudo-method syntax (for arrays only), but this allows custom= izing the type when needed. But: is there a way to define functions corresponding to language operation= s (opEquals, opIndex, toString...) without creating a true type? Thank you, Denis -- -- -- -- -- -- -- vit esse estrany =E2=98=A3 spir.wikidot.com
Dec 07 2010
spir:But: is there a way to define functions corresponding to language operations (opEquals, opIndex, toString...) without creating a true type?You may find some trick to do something like that, but it's not how D is supposed to be used. In D operators belong in a struct/class/enum. "alias this" sometimes helps. Bye, bearophile
Dec 07 2010