Re: Eu's poor design

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

Andreas Rumpf wrote:

> 
> 
> Pete Lomax wrote:
> 
>>
>>On Mon, 18 Aug 2003 07:22:33 +0000, Andreas Rumpf <pfropfen at gmx.net>
>>wrote:
>>
>>
>>>I showed you. I can also show you 'forward', if you like:
>>>
>>>forward function b()
>>>
>>>function a()
>>> return b() + 1
>>>end function
>>>
>>>function b()
>>> return a() + 2
>>>end function
>>>
>>
>>LOL show that to your tutor, I dare you.
>>Whatever, it is not hard:
>>
>>integer brid
> 
> And again, Eu's type system is confusing! brid is not an integer really, 
> it is a pointer to a function!

More like an alias for a pointer to a function. It is an integer that 
references a table of references to functions.

You could always use deliberate conventions and a sneaky type declaration:

--------
type predeclare(object id) if integer(id) and
   id >= 0
then return 1 end if return 0 end type
--------
predeclare is_odd_ -- looks almost like part of Euphoria syntax...

function is_even(integer x)
   if    x < 0 then return is_even(-x)
   elsif x = 0 then return 1
   end if           return call_func(is_odd_, {x-1})
end function

function is_odd(integer x)
   if x = 0 then return 0
   end if        return is_even(x-1)
end function is_odd_ = routine_id("is_odd")
--------

This isn't a great way to determine whether a number is odd or even, but 
it's great as a dual recursion example. :)

-- 
[ Carl R White == aka () = The Domain of Cyrek = ]
[ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]

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

Search



Quick Links

User menu

Not signed in.

Misc Menu