jamiebuilds / ghost-lang

:ghost: A friendly little language for you and me.
302 stars 10 forks source link

Reference Or Clone? #42

Open hasezoey opened 4 years ago

hasezoey commented 4 years ago

In the examples given, it is unclear to me: what are references to values and what are "clones"?

like the following:

let string1 = "String 1"
let string2 = string1 # will this be a clone or a reference?
let obj1 = {
  key1: "Key 1"
}
let obj2 = obj1 # will this be a clone or a reference?

(2 examples, because in a language like JavaScript, a primitive is a clone, and an object is a reference)

and for functions:

let func1 = fn (var1, var2) { } # will var1 & var2 be clones of the original values, or references?