dibyendumajumdar / ravi

Ravi is a dialect of Lua, featuring limited optional static typing, JIT and AOT compilers
http://ravilang.github.io/
Other
1.16k stars 60 forks source link

Improve type deduction for cond and x or y #216

Closed XmiliaH closed 3 years ago

XmiliaH commented 3 years ago

Allow type deduction for cond and x or y when x and y are of the same type or numbers.

dibyendumajumdar commented 3 years ago

hi, do you think we should change the values assigned to the enum so that it is like Lua does - i.e. numbers have a common bit, and a variant bit? Similarly table, integer array and float array? Also should we split out true and false like its done in LuaJIT / Lua 5.4?

dibyendumajumdar commented 3 years ago

btw I liked your previous PR more because it was more generic I felt. Although it posed a problem because of the impact on my other compiler work - I do think maybe it is the better way forward. Maybe we need to first do a step that sorts out the type information and how it is used. Then the actual type deduction improvement can follow. What do you think?

XmiliaH commented 3 years ago

I too like the other, more generic way more. Therefore I implemented it first instead of this approach.

dibyendumajumdar commented 3 years ago

Okay lets go back to that then? I don't know if you want to refresh it or leave it with me ...

XmiliaH commented 3 years ago

I didn't look into the compiler part yet. So I would currently leave it with you.

dibyendumajumdar commented 3 years ago

Okay - I will work on that. I merged it to a branch so that I can revise it before merging to master

dibyendumajumdar commented 3 years ago

Hi @XmiliaH please review https://github.com/dibyendumajumdar/ravi/tree/new_type_info

XmiliaH commented 3 years ago

I would bump the version of the binary format due to the change from byte to integer. Maybe also allow to load older versions with a mapping from the old values to the new ones.