[Progress Communities] [Progress OpenEdge ABL] CASE / WHEN statements should handle dynamic references with undefined type better

  • Thread starter Thread starter frank.meulblok
  • Start date Start date
Status
Not open for further replies.
F

frank.meulblok

Guest
Already discussed with Support, and directed here to see if community interest is large enough to justify the work involved... For context: "dynamic references with undefined type" means references where at compile-time the data type can't be known. Most common ones are probably the :BUFFER-VALUE attribute, and return values from DYNAMIC-FUNCTION & DYNAMIC-INVOKE. Compiler will defer type checking until runtime, and at runtime an implicit conversion is used if types don't match. Example: FIND FIRST customer. IF BUFFER customer::custnum = "1" THEN MESSAGE "bla". IF BUFFER customer::custnum NE BUFFER customer::NAME THEN MESSAGE "bla". The CASE statement specifically does NOT handle this smoothly. - If there's an undefined datatype reference in the CASE or a WHEN phrase, but the other phrases use expressions with a fixed datatype, that gives compile-time error "Incompatible datatypes in CASE and a WHEN branch expression. (3536)". - If all phrases in the CASE statement are undefined types, the code compiles, but crashes at runtime if the types don't match there. So to avoid issues, you need to add code to force data type conversions for the undefined datatype references. In most use cases that would be easy enough because you'll only have a dynamic reference in the CASE phrase, example: CASE STRING(BUFFER customer::custnum): WHEN "1" THEN MESSAGE "bla". WHEN "2" THEN MESSAGE "not bla". OTHERWISE MESSAGE "bla bla". END CASE. All the same, this type of inconsistency would look bad in any language as it requires extra coding, and it's confusing because other parts of the language handle things just fine. (Or at least, based on a set of reasonable assumptions)

Continue reading...
 
Status
Not open for further replies.
Back
Top