Discussion:
Question about unary plus
(too old to reply)
Dan
2004-07-08 16:58:45 UTC
Permalink
Hi,

Looking at the assignment 5 spec, it states that:

" An attempt to perform unary addition should be reported as an error."

I have to ask why? Shouldn't an unnecessary plus symbol simply be ignored?
This is the behaviour found in java. Also, it makes more sense for it to be
ignored from a mathematical point of view: 4, and +4 are the same thing, so
why should +4 cause an error?

Does implementing a unary plus cause problems elsewhere? or is this just to
make our lives easier? (if it is, thanks!)

--Dan
Troy Mark Gonsalves
2004-07-09 19:57:04 UTC
Permalink
Post by Dan
" An attempt to perform unary addition should be reported as an error."
I have to ask why? Shouldn't an unnecessary plus symbol simply be ignored?
This is the behaviour found in java. Also, it makes more sense for it to be
ignored from a mathematical point of view: 4, and +4 are the same thing, so
why should +4 cause an error?
Does implementing a unary plus cause problems elsewhere? or is this just to
make our lives easier? (if it is, thanks!)
Just to make things easier.
Jaewook Chung
2004-07-09 20:57:39 UTC
Permalink
Unary subtraction is allowed in SL specification, but there is no mentioning
about unary addition. Yes, it make sense to have unary addition, but you
should follow the A5 description and report unary addition as an error.

Hint: not allowing unary addition doesn't seem to make A5 easier. But it is
very easy to detect the unary addition.

J. Chung
Post by Dan
Hi,
" An attempt to perform unary addition should be reported as an error."
I have to ask why? Shouldn't an unnecessary plus symbol simply be ignored?
This is the behaviour found in java. Also, it makes more sense for it to be
ignored from a mathematical point of view: 4, and +4 are the same thing, so
why should +4 cause an error?
Does implementing a unary plus cause problems elsewhere? or is this just to
make our lives easier? (if it is, thanks!)
--Dan
Loading...