1. Phix: Strange Behavior
- Posted by andreasWagner 2 weeks ago
- 391 views
Hallo,
While working with maze3d.ex from this thread: https://openeuphoria.org/forum/139479.wc?last_id=139488
Something strange happened to me; I tried to incorporate it into a small program to illustrate the issue. Of course, this causes the program to crash under Phix.
The function is'nt actually necessary in principle.
Maybe it's just me, and I'm missing something.
--/* include std/console.e --*/ constant RAYWHITE={245,245,245,0} atom COLOR_IS_SEQ = sequence(RAYWHITE) ?COLOR_IS_SEQ function mzRGB(integer r, integer g, integer b, integer a = 255) if COLOR_IS_SEQ then return {r, g, b, a} else return r + g * 256 + b * 65536 + a * 16777216 end if end function ?RAYWHITE ?sequence(RAYWHITE) ?mzRGB(1,2,3) COLOR_IS_SEQ = 1 ?mzRGB(1,2,3) wait_key()
Result with Phix:(unexpected)
1
{245,245,245,0}
1
4278387201
{1,2,3,255}
Result with Euphoria:(expected)
1
{245,245,245,0}
1
{1,2,3,255}
{1,2,3,255}
Andreas
2. Re: Phix: Strange Behavior
- Posted by RobertS 2 weeks ago
- 395 views
constant RAYWHITE={245,245,245,0} atom COLOR_IS_SEQ = sequence(RAYWHITE) ?COLOR_IS_SEQ ?COLOR_IS_SEQ
Result:
1
0
3. Re: Phix: Strange Behavior
- Posted by Icy_Viking 2 weeks ago
- 470 views
Did you forget to include raylib.e in your program file?
4. Re: Phix: Strange Behavior
- Posted by RobertS 2 weeks ago
- 344 views
Did you forget to include raylib.e in your program file?
This has nothing to do with raylib.e - the variable that receives the result of the function sequence() mysteriously changes its value after it is printed ...
constant s = {} atom x x = sequence(s) ? x ? x
Result:
1
0
5. Re: Phix: Strange Behavior
- Posted by petelomax 2 weeks ago
- 335 views
Wow! Thanks for finding that!
The vast majority of programs rely exclusively on opSq0, which is fine and leaves e/rdx set to 0/1, however
opSq, which stores that 0/1 in a variable, is quite astonishingly simply backwards and always has been!
In many cases the compiler mitigates that by knowing what it should be rather than reloading from memory.
I even left myself the correct 32-bit code commented out and incorrectly optimised away...
Replace two uses of opAtomContinue in builtins\VM\pType.e from line 192 onwards with the two lines following it.
:%opSq -- [e/rdi]=sequence(e/rax) (NB: opSeq is dest=(p1=p2))
----------
[32]
-- calling convention
-- lea edi,[dest]
-- mov eax,[src] -- ref of src
-- mov ecx,src -- var no of src
-- call opSq -- [edi]:=sequence(eax)
-- xor ebx,ebx
cmp eax,h4
mov edx,[edi]
jl :edi0
:!opSqe92 -- exception mapped to e94vhnbaavecxfeh [DEV]
test byte[ebx+eax*4-1],0x80
-- jmp :opAtomContinue // ***WRONG*** (1/11/2026!)
jz :edi0
jmp :edi1
-- jz edi0
-- mov dword[edi],1
-- cmp edx,h4
-- jle @f
-- sub dword[ebx+edx*4-8],1
-- jz :%pDealloc
-- @@:
-- ret
[64]
-- calling convention
-- lea rdi,[dest]
-- mov rax,[src] -- ref of src
-- mov rcx,src -- var no of src
-- call opSq -- [rdi]:=sequence(rax)
mov r15,h4
mov rdx,[rdi]
cmp rax,r15
jl :edi0
:!opSqe92 -- exception mapped to e94vhnbaavecxfeh [DEV]
test byte[rbx+rax*4-1],0x80
-- jmp :opAtomContinue // ***WRONG*** (1/11/2026!)
jz :edi0
jmp :edi1
[]
You will of course need to run "p -c p" for these changes to take proper effect.
7. Re: Phix: Strange Behavior
- Posted by andreasWagner 2 weeks ago
- 325 views
Thank you,
that fixed the problem.
Andreas

