free function on arrays & language operations
Jonathan M Davis
jmdavisProg at gmx.com
Tue Dec 7 10:31:25 PST 2010
On Tuesday, December 07, 2010 10:10:31 spir wrote:
> Hello again,
>
> I started to be found of defining types which basically are arrays with
> free functions, instead of creating a struct or class with methods. Not
> only we still have pseudo-method syntax (for arrays only), but this allows
> customizing the type when needed. But: is there a way to define functions
> corresponding to language operations (opEquals, opIndex, toString...)
> without creating a true type?
No. You need to create an actual type for that sort of thing. Arrays aren't
intended to be used for creating types. strings are kind of a special case in
that regard, and they're not exactly their own type anyway.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list