Re: Over exaggerated negative post on reddit programming

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
euphoric said...
jimcbrown said...

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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu