You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
As it stands, Blade classes are first class and can be used in almost anything including iterables, values and more. It will greatly increase consistency to have Blade classes support operator overloading from classes.
Proposed Solution
Since today, Blade classes can become iterators by implementing the @iter and @itern decorators, Blade can employ decorators for operator overloading support.
E.g.
class A {
@+(a2) {
return self.value + a2.value
}
}
var a1 = A()
a1.value = 5
var a2 = A()
a2.value = 7
echo a1 + a2
The above sample code should print 12 to terminal.
Alternative Solution
As an alternative, we could use a keyword operator.
For example:
class A {
operator + {
return self.value + __arg__.value
}
}
var a1 = A()
a1.value = 5
var a2 = A()
a2.value = 7
echo a1 + a2
This will at best require an extra conditionally valid keyword __arg__.
The text was updated successfully, but these errors were encountered:
It feels very natural.
It might also be important to keep negating values in mind (if this is to be implemented). So with your suggested syntax above, how would I do:
Hmm, to me @-(other) {} does not seem to align with decorators. I think that introducing the keyword operator might be a good way to clarify different types of functionality.
Is your feature request related to a problem? Please describe.
As it stands, Blade classes are first class and can be used in almost anything including iterables, values and more. It will greatly increase consistency to have Blade classes support operator overloading from classes.
Proposed Solution
Since today, Blade classes can become iterators by implementing the
@iter
and@itern
decorators, Blade can employ decorators for operator overloading support.E.g.
The above sample code should print
12
to terminal.Alternative Solution
As an alternative, we could use a keyword
operator
.For example:
This will at best require an extra conditionally valid keyword
__arg__
.The text was updated successfully, but these errors were encountered: