1. Userdefined datatypes
- Posted by ZNorQ Mar 06, 2015
- 1508 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
- 1513 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
- 1578 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
- 1537 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
- 1423 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
- 1429 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
- 1409 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
- 1377 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