Re: Error Trapping

new topic     » goto parent     » topic index » view thread      » older message » newer message

>"Boehme, Gabriel" wrote:
>>
>>
>> s = routine_info(id)
>>
>> Where s would be a sequence containing the relevant data:
>>
>> R_TYPE = 1,     -- integer value indicating if this is a
>>                 -- procedure or a function
>>     R_PROCEDURE = 1,
>>     R_FUNCTION = 2,
>>
>> R_PARM_DATA = 2 -- sequence containing the routine id's of all the
>>                 -- parameter types for this routine
>>                 -- number of parms = length(s[R_PARM_DATA])
>>
>
>I like the sound of this idea, and to me it looks elegant enough to fit
>into the current Euphoria Language Syntax, it is consistent with some of
>the other functions.

A library follows. (i wanne hear 'thank you' .. blink
All you have to do now, is call either register_function or register_procedure
tell the routine-id and those of its parameters
and you're done.

--- whatyouwant.e

sequence rtypes, rdata

global procedure register_function (integer rp, sequence rd)
    if rp > length(rtypes) then
        rtypes &= repeat (-1,  rp-length(types) )
        rdata &= repeat ("", rp-length(types) )
    end if
    rtypes[rp] = R_FUNCTION
    rdata[rp] = rd
end procedure

global procedure register_function (integer rp, sequence rd)
    if rp > length(rtypes) then
        rtypes &= repeat (-1,  rp-length(types) )
        rdata &= repeat ("", rp-length(types) )
    end if
    rtypes[rp] = R_PROCEDURE
    rdata[rp] = rd
end procedure

global function routine_info (integer rp)
    if rp > length(rtypes) then
        return -1
    elsif rtype[rp] != -1 then
        return {rtypes[rp], rdata[rp]}
    else
        return -1
    end if
end function

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl
ralf_n at email.com
Uin: 9389920

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu