1. Userdefined datatypes
- Posted by ZNorQ Mar 06, 2015
- 1509 views
Hi,
I've created an own data-type called "byte";
type byte( object nByte ) return ( integer( nByte ) and nByte >= 0 and nByte <= 255 ) end type
With this, I was hoping that the following code would "survive" a data-type check;
sequence myType = "somesequenceiwanttocheck" if byte( myType ) then <statements> else <statements> end if
However, it doesn't... Any thoughts?
Kenneth aka ZNorQ
2. Re: Userdefined datatypes
- Posted by ZNorQ Mar 06, 2015
- 1514 views
Ah forget it! Stupid me, I assumed short-circuit applied to the...
return ( integer( nByte ) and nByte >= 0 and nByte <= 255 )
... however I tried modifying the code to the following;
type byte( object nByte ) if sequence( nByte ) then return false else return ( integer( nByte ) and nByte >= 0 and nByte <= 255 ) end if end type
New motto; THINK, before you post... Oo
Kenneth
3. Re: Userdefined datatypes
- Posted by Ekhnat0n Mar 06, 2015
- 1580 views
Not a very Norwegian first name Kenneth ;)
My name Antoine can be explained by the fact that my granny was French
4. Re: Userdefined datatypes
- Posted by DerekParnell (admin) Mar 06, 2015
- 1539 views
I've created an own data-type called "byte";
It's probably just a style thing, but the way I code these is more along the lines of ...
type byte( object nByte ) if not integer( nByte ) then return 0 end if if nByte < 0 then return 0 end if if nByte > 255 then return 0 end if return 1 end type
5. Re: Userdefined datatypes
- Posted by ZNorQ Mar 07, 2015
- 1424 views
Not a very Norwegian first name Kenneth ;)
My name Antoine can be explained by the fact that my granny was French
Correct, and on top of that I have a Swedish surname (Sweedish blood in the family tree way back) ;)
6. Re: Userdefined datatypes
- Posted by ZNorQ Mar 07, 2015
- 1431 views
I've created an own data-type called "byte";
It's probably just a style thing, but the way I code these is more along the lines of ...
type byte( object nByte ) if not integer( nByte ) then return 0 end if if nByte < 0 then return 0 end if if nByte > 255 then return 0 end if return 1 end type
Would it be because of readibility, execution efficiency - or something else?
Regards Kenneth/ZNorQ
7. Re: Userdefined datatypes
- Posted by DerekParnell (admin) Mar 07, 2015
- 1411 views
It's probably just a style thing, but the way I code these is more along the lines of ...
Would it be because of readibility, execution efficiency - or something else?
Sure, both those plus plus maintainability and debugging.
It is easy to insert or modify a condition when they are all laid out in a simple format.
Debugging, using trace(), is easier to see when stepping through one condition at a time.
8. Re: Userdefined datatypes
- Posted by ZNorQ Mar 09, 2015
- 1379 views
It's probably just a style thing, but the way I code these is more along the lines of ...
Would it be because of readibility, execution efficiency - or something else?
Sure, both those plus plus maintainability and debugging.
It is easy to insert or modify a condition when they are all laid out in a simple format.
Debugging, using trace(), is easier to see when stepping through one condition at a time.
But short-circuit evaluation counts for efficiency too, right?
Kenneth / ZNorQ