Open leios opened 3 years ago
O.o The zero confuses me
@leios Oh wait, found it: https://github.com/CliMA/Impero.jl/blob/master/src/abstract_core.jl#L64
I think there was a reason for adding the zero previously right?
Ah, ok. I vaguely remember now. Sorry, that was my bad.
The 0 is the neutral element of addition. I should also have a 1 to deal with the neutral element of multiplication (but, uh... cough, cough). This would just help dealing with potentially empty sets, but I think it can be entirely removed without consequence. Let me do that today.
I fixed the Base.show issue. I honestly don't remember what I was thinking when I did that!
I do want to ask about what we want to do with these operators in the future. When adding a bunch of numbers together in Julia, it's kinda nary anyway:
julia> x = 1;
julia> dump(:(x+x+x))
Expr
head: Symbol call
args: Array{Any}((4,))
1: Symbol +
2: Symbol x
3: Symbol x
4: Symbol x
As a note: I think the LLVM code does things slightly differently. It seems like it turns everything into binary operators.
I could try to find a way to extend the +
and *
operators to all be nary... This might help with certain optimizations in the future, but I am not sure where I actually need to go with this PR right now so I might work on other things for the next few days and come back to this later this week!
I was just getting used to Impero dev again (trying to turn it into a general symbolic equation tool). I completely forgot what I was trying to do with nary operators before, but now I have something that works a bit, but returns the following:
I gotta be honest. I don't know where the 0 is coming from. It's also in the
*
operator, which obviously makes everything fail. Any ideas?Maybe it's best to just remove nary operators and move on?