Open fingolfin opened 3 months ago
The complicated case is something like polynomial_ring(QQ, :x => (1:3, 5, 1:3))
. Do we wanna error here as well? Currently, this behaves as 2.ii. above (so taking 5
as 5:5
). Changing this could break downstream.
The two ways I see here:
5
as 5:5
)_variable_names
returns a single symbol instead of a vector. This then fails in case of polynomial_ring(QQ, :x => 5)
but still allows polynomial_ring(QQ, :x => (1:3, 5, 1:3))
.I think allowing :x => (1:3, 5, 1:3)
while :x => 5
fails is a misfeature if not a bug. Are you aware of any code or anyone actually relying on this? Otherwise I'd just make that illegal as we..
I think allowing
:x => (1:3, 5, 1:3)
while:x => 5
fails is a misfeature if not a bug. Are you aware of any code or anyone actually relying on this? Otherwise I'd just make that illegal as we..
I thought I have seen this in a doctest somewhere in VarNames.jl
, but after looking for it again, I don't find it anymore. I thus agree with you that 3 is not a good option.
Just found https://github.com/Nemocas/AbstractAlgebra.jl/blob/6be27f6e6d5352c8564996ef17a57f9c8c71dffc/src/misc/VarNames.jl#L19 in a related docstring. This currently documents 2.ii., although it does not work.
Right now
polynomial_ring(QQ, :x => 3)
leads to an error that is not very helpful:I'd like to improve this. The two major options are:
polynomial_ring(QQ, :x => 1:3)
polynomial_ring(QQ, :x => 3:3)
The fact that there are at least two interpretations might suggest we should prefer the error. Then again I am not sure how natural each is? For me I comparatively often make this mistake because I think "I want three x-variables", so I use
:x => 3
when I really mean:x => 1:3
. The only reason I am considering the other option is that it is based on Julia semantics: one can "iterate" over an integer, and the integer is treated as if it was a 0-dimensional container with a single entry (itself). Honestly I don't like this, but it is what it is, so one might just lean into it...Still the safe route would be 1. An error can always be turned into working code later on.
Any thoughts on this?