Those don't seem to be viable solutions. In fact
julia> a=2
2
julia> b=Ref(a)
Base.RefValue{Int64}(2)
julia> b += 3
ERROR: MethodError: `+` has no method matching +(::Base.RefValue{Int64},
::Int64)
and also how do you define a 0-dimensional array?
a=Array{Float64,0}()
ERROR: MethodError: `convert` has no method matching
convert(::Type{Array{Float64,0}})
This may have arisen from a call to the constructor Array{Float64,0}(...),
since type constructors fall back to convert methods.
Il giorno sabato 3 ottobre 2015 18:07:51 UTC+2, Jameson ha scritto:
>
> the `Ref` type or the single-valued `Array{T,0}` provides this ability for
> Julia.
>
> On Fri, Oct 2, 2015 at 5:10 PM Carlo Lucibello <[email protected]
> <javascript:>> wrote:
>
>> Hi julians,
>> I'd like to emulate the following behaviour from C++
>>
>> class A{
>> public:
>> double x;
>> }
>>
>> class B{
>> public:
>> double& x;
>> }
>> A a(1);
>> B b(a.x);
>> a.x=2;
>> assert(b.x == 2);
>>
>> Whilie it would be easy to obtain this behaviour with `composite` types,
>> since they are passed by referece, for elementary types, such as Float64,
>> thi is not possible since they have a sort of by vlue semantic (yes, I know
>> it's not exactly like that, but still...)
>>
>> Greetings,
>> Carlo
>>
>