Euphoria Ticket #139: object()

object() should always return 1 but should crash when uninitialized variables are passed to it.

Details

Type: Feature Request Severity: Major Category: Interpreter
Assigned To: unknown Status: Won't Fix Reported Release:
Fixed in SVN #: View VCS: none Milestone:

1. Comment by jimcbrown Feb 25, 2010

This would be just reverting to the 3.1.1 behavior.

2. Comment by SDPringle Mar 04, 2010

Okay, you're right. I liked the old behavior better.

3. Comment by jimcbrown Mar 04, 2010

Why?

The old behavior had object() as a useless function. It just returned a constant value...

The new behavior, of when object() returns zero, is fully backwards compatible (all possible uses of object() in 3.1.1 code are unchanged and work exactly the same) while object() itself is extended so it actually can be used to do something meaningful.

Now, there is also a typing system in object() (so it sometimes returns 2,3,4 instead of just 1 or 0). This is technically not backwards compatible, and breaks the paradigm of types always returning 1 or 0, but in practice it is a very small and simple change to fix any code that might break (if the code is checking for object(x) == 1 then it just needs to be changed to cheeck for object(x) >= 1 ... most code I've seen that uses object(x) just does "if object(x) then", which is a usage that won't break with this new change).

4. Comment by SDPringle Oct 23, 2010

I think I am out voted here. I dislike anything that makes things different in the translated code vs. the interpreted code.

Suppose translator initialized all uninitiated values as NOVALUE rather than 0 then we would have the same behavior translated or interpreted. I think most of us would prefer this to the current behavior.

In translating, "sequence foo" becomes "int foo = 0;". Now if "sequence foo" would become "int foo = NOVALUE;" then we could rely on object() to do the same translated or interpreted.

5. Comment by DerekParnell Oct 23, 2010

I'm kind of warming to that suggestion Shawn. I'll sleep on it and comment tomorrow.

6. Comment by mattlewis Oct 23, 2010

The real solution is to fix the translator, I think. We need to initialize to NOVALUE instead of zero, and it should work the same way.

7. Comment by SDPringle Oct 25, 2010

I think the comments have come to an agreement different from how it started out. Let's open a new ticket?

Search



Quick Links

User menu

Not signed in.

Misc Menu