noname icon indicating copy to clipboard operation
noname copied to clipboard

Clone function?

Open mimoo opened this issue 3 years ago • 6 comments

Currently everything is passed by reference in the language. There is no such thing as passing by value.

You can mutate local variables if there's the keyword mut.

When you pass a variable to a function, I believe it can mutate the variable eventhough it might not be mutable... we need to change that. Perhaps functions should annotate what args they might want to modify?

mimoo avatar Oct 01 '22 00:10 mimoo

Also. If I want to copy/clone a var, it should be easy.

Perhaps let x = y is enough.

Create the number of necessary internal var and wire them?

Do I need to wire them? Perhaps I don't because things are indeed passed by value lol

What does reassign do again?

mimoo avatar Oct 01 '22 00:10 mimoo

Ok proposition: dont allow mutation of arguments of functions in general. Like that if someone tried they get an error. Easy

mimoo avatar Oct 01 '22 01:10 mimoo

It also sounds like let x = y should already work, as we would reassign vars on x and not y if we try to mutate x!

mimoo avatar Oct 01 '22 01:10 mimoo

Everything is actually copy on write!

mimoo avatar Oct 01 '22 01:10 mimoo

If var is mutable, pass by pointer, otherwise pass by cvar

A var is in noname A cvar is internal A fvar is a field ellement or cellvar

mimoo avatar Oct 01 '22 20:10 mimoo

Call it reference not pointer. Or even better "mutable reference"

mimoo avatar Oct 01 '22 21:10 mimoo