wila
28-Nov-2020, 06:38 AM
Hi,
The request for having null support in DataFlex has come up every now and then.
I do think it would be good to have, but also see the problems with it.
For example I just had a bug report last week from my new product (vimarun) where a customer bumped into a runtime bug. Basically it boiled down to the side effect of me not taking care of a null problem...
So last night my wife asks me to explain something in rust.
She's studying that now and loves it (for good reason!)
The problem was "what is an option enum?"
See this chapter in the rust doc (read it whole) : Defining an enum
(https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html)
She comes from a loosely typed language (javascript) which is even more loosely typed than DataFlex, but it has support for null.
So while she understands the null concept, the problem with null first had to be explained.
Well OK I had a bug I could show :D
The solution in rust with having option<T> is elegant and can help a lot while avoiding some of the problems with null.
Can we have this in DataFlex too please ;)
Example code on how it could look like once implemented in the compiler & runtime.
// Wont Even Compile, type mismatch!
Integer iX
Option<Integer> iY
Integer iSum
Move (iY + iY) To iSum
// Compiles
Integer iX
Option<Integer> iY
Integer iSum
if (iY.none=false) Begin
Move (iY + iY.Some) To iSum
End
Else ;
Showln 'Y has no value!'
Thanks Oy
--
Wil
The request for having null support in DataFlex has come up every now and then.
I do think it would be good to have, but also see the problems with it.
For example I just had a bug report last week from my new product (vimarun) where a customer bumped into a runtime bug. Basically it boiled down to the side effect of me not taking care of a null problem...
So last night my wife asks me to explain something in rust.
She's studying that now and loves it (for good reason!)
The problem was "what is an option enum?"
See this chapter in the rust doc (read it whole) : Defining an enum
(https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html)
She comes from a loosely typed language (javascript) which is even more loosely typed than DataFlex, but it has support for null.
So while she understands the null concept, the problem with null first had to be explained.
Well OK I had a bug I could show :D
The solution in rust with having option<T> is elegant and can help a lot while avoiding some of the problems with null.
Can we have this in DataFlex too please ;)
Example code on how it could look like once implemented in the compiler & runtime.
// Wont Even Compile, type mismatch!
Integer iX
Option<Integer> iY
Integer iSum
Move (iY + iY) To iSum
// Compiles
Integer iX
Option<Integer> iY
Integer iSum
if (iY.none=false) Begin
Move (iY + iY.Some) To iSum
End
Else ;
Showln 'Y has no value!'
Thanks Oy
--
Wil