Jump to content

Introspection: Difference between revisions

m
→‎{{header|Retro}}: update for retro12
m (→‎{{header|Retro}}: update for retro12)
Line 1,776:
 
=={{header|Retro}}==
This will exit if the minor version is less than 32019.6:
 
<lang Retro>version@Version ^strings'splitAtChar:#201906 . drop toNumber 3 <lt+ &bye ifTrueif</lang>
 
The existance of functions can be checked using find'''d:lookup'''. In this, a helper function is provided to improve readability.
A better way is to check the build number. This will exit if the build is lower than
the 11.0 release:
 
<lang Retro>build toNumber 1309798464 < &bye ifTrue</lang>
( Checks for existance of "bloop" and "n:abs" )
 
~~~
The existance of functions can be checked using find. In this, a helper function is provided to improve readability.
: executeByName ( $s- )
 
find dropd:lookup [ @d->:xt fetch ] [ @d->:class fetch ] bi withClasscall ;
<lang Retro>
( Checks for existance of "bloop" and "abs" )
: executeByName ( $- )
find drop [ @d->xt ] [ @d->class ] bi withClass ;
 
"'bloop" "'n:abs" [ find nip ] bi@ and
[ "'bloop" executeByName "'n:abs" executeByName ] ifTrue</lang>if
~~~</lang>
 
Retro has no direct way to check for data types of functions. Assuming that a word class is defined for integer variables, we could do something like this:
 
<lang Retro>
#0 #0 last [ dup @d->:class fetch &.class:integer =eq? [ @d->:xt @fetch + [ 1+n:inc ] dip ] [ drop ] ifchoose ] ^types'LIST d:for-each@
</lang>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.