Re: type string
Daniel Berstein <daber at PAIR.COM> wrote
>I tried with a direct return statement, but short-circuit evaluation only
>works for if and while statements. I understand that short-circuit may
>render unwanted results for general purpose boolean operations, but in the
>context of a type declaration, where only true/false values can be returned
>(same case as if and while) there could be a way to override the default
>behaviour. [snip]
You're forgetting the possibility of recursive type declarations. The end
result of the type should be a boolean value, this is true. But if a type is
recursively calling itself, it *may* wish to return a sequence of boolean
values to itself. (I can't currently think of any examples, but I'm assuming
there are situations where this would be handy.) Euphoria can't just
"assume" we always want short-circuit evaluation for our type-function
return statements.
Besides, if return statements worked differently for types than they did for
functions, how much confusion do you think *that* would cause? Would a
type's return statement have to work differently when called as a function,
as opposed to being called internally as part of a type-check? I'd love to
have short-circuit evaluation for type return statements, but I don't see a
way of doing it that wouldn't create more confusion than it would solve.
Gabriel Boehme
|
Not Categorized, Please Help
|
|