Hi,
When I try to overload || with some_function, it says the || is not a
symbol. Any idea?
Also, is it possible to overload + to be a unary postfix operator?
Thanks,
Hi,
When I try to overload || with some_function, it says the || is not a
symbol. Any idea?
Also, is it possible to overload + to be a unary postfix operator?
Thanks,
Only functions can be overloaded.
|| and && are already declared as macros in prelude/SATS/bool.sats, so
they cannot be overloaded. However, if you do
symintr &&
overload && with
Then it works. But after this, && no longer refers to the original macro
definition.
postfix +
overload + with On Wednesday, August 6, 2014 1:41:29 PM UTC-4, Steinway Wu wrote:
Hi,
When I try to overload || with some_function, it says the || is not a
symbol. Any idea?Also, is it possible to overload + to be a unary postfix operator?
Thanks,
infixl 10 +
10 is the precedence of ‘+’.
Suppose you have an expression ‘1 + 2 ++ 3’;
if ++ has a higher precedence, then the expression
is parsed as 1 + (2 ++ 3); if ++ has a lower precedence,
you get (1 + 2) ++ 3.
overload + with foo of 10
Say you also have:
overload + with foo2 of 11
Suppose you have (x + y); if (x + y) can be translated to both foo(x, y)
and foo2(x, y),
the foo2 is chosen (as it has a higher overloading value than foo).On Sunday, May 10, 2015 at 10:40:48 PM UTC-4, Yannick Duchêne wrote:
What is the difference between this
infixl 10 +
overload + with fooand this
infixl +
overload + with foo of 10?
Do the
10
stands for the same precedence or do both means something
different?Le mercredi 6 août 2014 20:05:28 UTC+2, gmhwxi a écrit :
Only functions can be overloaded.
|| and && are already declared as macros in prelude/SATS/bool.sats, so
they cannot be overloaded. However, if you dosymintr &&
overload && withThen it works. But after this, && no longer refers to the original macro
definition.
- is current an infix operator. You need to do:
postfix +
overload + with
Only functions can be overloaded.
But the function an operator symbol designates, may a polymorphic function…
or it does work with polymorphic functions?
That’s not the same as full overloading, this is just I feel this question
is worth to be asked.
Thanks! Although I don’t think that’s feasible since it overrides the
logical operator. But this is a very clear answer.On Wednesday, August 6, 2014 2:05:28 PM UTC-4, gmhwxi wrote:
Only functions can be overloaded.
|| and && are already declared as macros in prelude/SATS/bool.sats, so
they cannot be overloaded. However, if you dosymintr &&
overload && withThen it works. But after this, && no longer refers to the original macro
definition.
- is current an infix operator. You need to do:
postfix +
overload + withOn Wednesday, August 6, 2014 1:41:29 PM UTC-4, Steinway Wu wrote:
Hi,
When I try to overload || with some_function, it says the || is not a
symbol. Any idea?Also, is it possible to overload + to be a unary postfix operator?
Thanks,
Yes, polymorphic functions can be overloaded.
Also, function templates can be overloaded as well.On Wednesday, August 6, 2014 2:48:46 PM UTC-4, Yannick Duchêne wrote:
Le mercredi 6 août 2014 20:47:22 UTC+2, Yannick Duchêne a écrit :
But the function an operator symbol designates, may a polymorphic
function… or it does work with polymorphic functions?Sorry, typo. Please, read: “or it does not work with polymorphic
functions?”
But the function an operator symbol designates, may a polymorphic
function… or it does work with polymorphic functions?
Sorry, typo. Please, read: “or it does not work with polymorphic
functions?”
This may not be the solution you are looking for, but in ATS contrib, the
file ./contrib/libfloats/TEST/test_LAgmat.dats has a macdef (the first one)
that allows ^t to work as a postfix transpose operator.
Brandon Barker
brandon…@gmail.comOn Wed, Aug 6, 2014 at 1:41 PM, Steinway Wu stein...@gmail.com wrote:
Hi,
When I try to overload || with some_function, it says the || is not a
symbol. Any idea?Also, is it possible to overload + to be a unary postfix operator?
Thanks,
–
You received this message because you are subscribed to the Google Groups
“ats-lang-users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/cb04c44d-6fc2-4e8a-a8e5-78701b6c7e57%40googlegroups.com
https://groups.google.com/d/msgid/ats-lang-users/cb04c44d-6fc2-4e8a-a8e5-78701b6c7e57%40googlegroups.com?utm_medium=email&utm_source=footer
.
What is the difference between this
infixl 10 +
overload + with foo
and this
infixl +
overload + with foo of 10
?
Do the 10
stands for the same precedence or do both means something
different?Le mercredi 6 août 2014 20:05:28 UTC+2, gmhwxi a écrit :
Only functions can be overloaded.
|| and && are already declared as macros in prelude/SATS/bool.sats, so
they cannot be overloaded. However, if you dosymintr &&
overload && withThen it works. But after this, && no longer refers to the original macro
definition.
- is current an infix operator. You need to do:
postfix +
overload + with