Al Thomas via vala-list writes:

>    > On Monday, 8 April 2019, 23:01:05 BST, Vivien Kraus 
> <[email protected]> wrote:
>> I have come across this weird closure thing. In other programming
>> languages, I would expect the closure in t to have a copy of i, but it
>> only has a reference. Is it expected?
>
> That's an interesting question!
>
> If you want a copy then pass it as an argument. If you want to usea
> variable from the enclosing scope then use a closure, but bewareif it
> changes in the enclosing scope it will change in the closure.
>
> That was my initial thought. Kind of made sense until I read you
> expected other programming languages to make a copy.
Now that I have checked in R and Python, you're right: it makes sense to
have a reference even for integers.  I don't understand my confusion.
Maybe I thought these kinds of implicit references were only for classes
and not simple types.

Sorry for that :)

Vivien
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to