Re: Over exaggerated negative post on reddit programming
- Posted by petelomax May 05, 2015
- 2297 views
Actually, the object() function allows you to test is a variable is unset...
I cannot imagine a case where this would be necessary. Are there examples of the utility of this functionality?
I can't think of any.
There is one case that immediately springs to mind:
--sequence table = {} sequence table procedure add(x) if not object(table) then table = {} end if table = append(table,x) end procedure
If you only invoke add() after the declaration of table, you do not need the object() test, but if you call it before, the (now commented out) table = {} may not have occurred. In the past I have frequently declared table and integer tinit = 0 (as integers can be and, at least in Phix, are assigned from literals at compile-time) to get around precisely this sort of thing. As written this is fixable, but if you want your table initialized with some run-time generated stuff, then it really has to be a separate flag or an object(table) test. I can accept that object() can always be replaced with a separate flag.
Pete