rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

Are default dimension-start indices 1 or 0? #5

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

Just recording our verbal discussion with an open issue. I believe we settled on 1 so as to favor fortran.

certik commented 1 year ago

There are no default dimension start for arrays. There is always an explicit lower index.

For strings, tuples and lists, I can't remember right now, it's either 0 or 1 based, we should document it.

rebcabin commented 1 year ago

If there is always an explicit lower index, does that mean [60] is not a valid dimension? It must be either [0 60] or [1 60] or [6 60] or whatever?

certik commented 1 year ago

Yes, that is my understanding, for array declarations. (It's different in the frontend language, but the frontend takes care of that.)

For indexing into arrays, you CAN specify just the upper index like :60, but then the meaning is lower_bound:60, where lower_bound is looked up in the array declaration where it is explicit.

rebcabin commented 1 year ago

will fix in master today

rebcabin commented 1 year ago

b5f1d83 fix issue 6

rebcabin commented 1 year ago

reopening as documentation reminder as requested by @certik