Here is another way to make make classname itself fail without changing its
implementation.

procedure classname(c)
   static builtin_classname
   initial builtin_classname := proc("classname", 0)
   &error := 1   # convert runtime errors to failures
   cname := builtin_classname(c)
   &error := 0
   return \cname
end

--Jafar



On Thu, Apr 18, 2013 at 9:40 PM, Jafar Al-Gharaibeh <to.ja...@gmail.com>wrote:

> Bruce,
>
>   In theory you can change any function to fail instead of  doing a
> runtime error, here is how I would do isClass()
>
> procedure isClass(c)
>    local cname
>    &error := 1   # convert runtime errors to failures
>    cname := classname(c)
>    &error := 0
>    return \cname
> end
>
> Cheers,
> Jafar
>
>
>
> On Thu, Apr 18, 2013 at 9:16 PM, Bruce & Breeanna Rennie <
> bren...@dcsi.net.au> wrote:
>
>>  Good morning Gentlemen,
>>
>> Further to my original note, I thought it might be useful to show the
>> procedure that I am using.
>>
>> procedure isClass(_val, _classname)
>>     local t := type(_val)
>>     if right(t,7) == "__state" then
>>         return classname(_val) == _classname
>>     else
>>         return fail
>> end
>>
>> If there is a better way to do this, I will be grateful to know it.
>>
>> regards and thanks
>>
>> Bruce Rennie
>>
>>
>> On 18/04/13 23:54, Bruce & Breeanna Rennie wrote:
>>
>> Clint and Jafar,
>>
>> How much effort would it be to change the behaviour of the function
>> "classname" to fail on a non-class value instead of aborting the
>> program? Are there any of the other functions that would be better off
>> failing instead of aborting?
>>
>> In its current form it is just about useless for writing generalised
>> code using it. I am finding that a routine using type gives me more
>> generic results.
>>
>> regards
>>
>> Bruce Rennie.
>>
>> ------------------------------------------------------------------------------
>> Precog is a next-generation analytics platform capable of advanced
>> analytics on semi-structured data. The platform includes APIs for building
>> apps and a phenomenal toolset for data science. Developers can use
>> our toolset for easy data analysis & visualization. Get a free 
>> account!http://www2.precog.com/precogplatform/slashdotnewsletter
>> _______________________________________________
>> Unicon-group mailing 
>> listUnicon-group@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/unicon-group
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Precog is a next-generation analytics platform capable of advanced
>> analytics on semi-structured data. The platform includes APIs for building
>> apps and a phenomenal toolset for data science. Developers can use
>> our toolset for easy data analysis & visualization. Get a free account!
>> http://www2.precog.com/precogplatform/slashdotnewsletter
>> _______________________________________________
>> Unicon-group mailing list
>> Unicon-group@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/unicon-group
>>
>>
>
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to