Re: Can you tell I reply to the whole digest?

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

>>You can do anything that you would normally do in a
>>procedure in a type.
>
>Yes. procedure -- not function. Sometimes it would be
>nice if type could return a value.
>As it is now, it returns (I think) a flag, saying: ok, make the
>assignment, or not_ok , so abort with error.

However you *can* call it just like any other function if you wonder if some
value could be considered to be of a certain type.


>example:
>type max5 (object x)
> return (x < 6)
>end type

Now you say this:

function beneath6 (object x)
    if not max5 (x) then
        x = 5
    end if
    return x
end function

It doesn't really help a lot, but I wanted to show you it *could* break any
existing code, at least when it wants to change the value to zero.  The
value is already used. That's why I think it is wrong to be able to declare
a type with anything else besides an object. It would crash instead of
return FALSE.

Example:

if integer ("Yes!") then
    puts (1, "No its not!"
end if

type max5 (integer x)
    return x < 6
end type

if max5 ("Yes!") then
    puts (1, "What ?? Didn't you crash?? ")
end if

It should print out nothing, instead the second if-statement generates a
crash.

>The reason I suggest this at all, is I don't think it
>would "break" any existing code, and it would be
>kinda handy.

It would break it, but I too must admit, it would be neat. Another way it
could break existing code is: when you turn type_check off you could
generate an error whereas it would run perfectly with type_check on. However
now, your program will crash in both cases, but the type_check would give
you better information what caused *really* caused the error, instead of the
statement that generated it.

Ralf Nieuwenhuijsen
nieuwen at xs4all.nl

BTW- Arthur, thanks for your comments. But I suppose being on this list
server (and the internet and turorials in general) is a *very* good thing
for my English.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu