See also the last comment
<https://github.com/JuliaLang/julia/issues/1974#issuecomment-219677416> in
that issue, which offers a macro solution.

On Fri, May 27, 2016 at 8:22 PM, Anonymous <[email protected]> wrote:

> interesting, well I'll look forward to it (hopefully) in the future then.
>
>
> On Friday, May 27, 2016 at 6:05:05 PM UTC-7, Cedric St-Jean wrote:
>>
>> You would need dot overloading for that, which is scheduled for 0.6
>> <https://github.com/JuliaLang/julia/issues/1974>, aka: planned, but
>> don't hold your breath.
>>
>> I believe the general recommendation is to have accessor functions
>> `get_x(f::Foo)` , `get_y(f::Foo)`, ideally with better names. Telling your
>> users to access the fields of an object directly exposes internals and will
>> prevent you from changing them in the future.
>>
>> On Friday, May 27, 2016 at 6:52:17 PM UTC-4, Anonymous wrote:
>>>
>>> Is there a way to have an alias to a field name?  For instance suppose I
>>> have
>>>
>>> type Foo
>>> x::Int
>>> end
>>>
>>> and I want to have Foo.y reference Foo.x, but I don't want an extra
>>> field y in order to save memory.  Of course why not just have
>>>
>>> type Foo
>>> y::Int
>>> end
>>>
>>> instead?  Because I wan't the user to access a field using a different
>>> name than the field name the programmer sees.. for reasons.
>>>
>>

Reply via email to