Phix vs OE syntax // switch
- Posted by _tom (admin) Apr 19, 2017
- 1460 views
[not a rant against Phix, because Phix switch "works" and ⵚE switch "works sometimes"]
[ observation, when ⵚE switch "does not work" using the Interpreter, the Translated version can work! ]
ⵚE follows this essential pattern:
for ... do ... end for while ... do ... end while switch ... do ... end switch
Phix sample
integer showprogress = 1 integer j = 0 for i=1 to 4 do switch i case 1,2: if showprogress then puts(1,"i is 1 or 2\n") end if j += i case 3: case 4: if showprogress then puts(1,"i is 3 or 4\n") end if j += i end switch end for if j!=10 then ?9/0 end if /* i is 1 or 2 i is 1 or 2 i is 3 or 4 i is 3 or 4 */
Phix has:
- invisible syntax
- introduced punctuation
This syntax does not follow established syntax conventions
ⵚE sample
integer showprogress = 1 integer j = 0 for i=1 to 4 do switch i do case 1,2 then if showprogress then puts(1,"i is 1 or 2\n") end if j += i case 3 then case 4 then if showprogress then puts(1,"i is 3 or 4\n") end if j += i end switch end for puts(1, "\n----------------------------\n") ? j if j!=10 then ?9/0 end if /* i is 1 or 2 i is 1 or 2 i is 3 or 4 ---------------------------- 7 attempt to divide by 0 */
ⵚE is consistent:
- "do" follows "switch"
- "then" instead of ":"
ⵚE follows established conventions
Yes, ⵚE is verbose. Yes, ⵚE is Friendly because syntax is uniform and follows simple rules.
_tom