Open github-actions[bot] opened 11 months ago
Basically, the idea is that e.g.
define :myNumber is :integer []
would auto-generate a type as if we had done:
define :myNumber [
init: method [num :integer][
this\value: num
]
add: method [that][
to :myNumber @[
add this\value (is? :myNumber that)? -> that\value -> that
]
]
; add the rest of the magic methods as shown above here
]
So, we could do sth like:
a: to :myNumber [10]
print a + 5 ; would print 15
Also, note: I'm planning to allow the conversion to given user-type from other type of params as well. For example, if a type's constructor takes one :integer
, why not allow for sth like to :myNumber 10
and forcefully require to :myNumber [10]
. I think it'd make sense ;)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
[OOP] Should we allow subtyping "some" of our built-in types? and if so: what would that mean? GenerateNumericSubtype* = """ init: method [v %TYPE%][ this\value: v ]
https://github.com/arturo-lang/arturo/blob/411617a1906063cf0adfd3ac06804dc4b29403a0/src/helpers/objects.nim#L28
8ce34ce0d713c6c74c7970f16589eeb82c0baa0f