Re: [Seed7-users] Seed7 - Ternary Assignment for Arrays and Hashes
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
|
From: Thomas M. <mer...@gm...> - 2025-11-13 09:00:57
|
Hey Zachary, The only reason for not supporting ternary expressions for arrays or hashes is: There could be cases where whole arrays or hashes would be copied unnecessarily. If one of the branches of a ternary operation creates a temporary value the other branch is forced to create a temporary value as well (by copying the data). In your example (with assignments) the copying always takes place. So your case is not the problem. If the ternary operator is defined for a type it can be used for any purpose and not just for assignments. Nothing hinders you to introduce the ternary operator for the type StringHash with: DECLARE_TERNARY(StringHash); If you define an array type you can do the same with it. I will consider introducing the ternary operator for arrays and hashes. I will search for ways to avoid unnecessary copies. Best regards Thomas |