December 07, 2010 Re: free function on arrays & language operations | ||||
---|---|---|---|---|
| ||||
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
|
Copyright © 1999-2021 by the D Language Foundation