Re: Discuss changing the behaviour of append()

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
mindwalker said...

But the question is will this change break someone's program. Could someone have depended on the append function to detect when the first parameter is an atom and to stop the program in that case.

The proposed change cannot break a working program. Theoretically it might make some bugs ever-so-slightly harder to detect, however when appending a sequence it is no help whatsoever, which means it isn't a sensible thing to rely on to help debug programs anyway, at least for the "got yer arguments back-to-front" problems.

Pete

Since append currently works the way I thought I remembered it did, I disagree Pete with your statement. The proposed change could break a working program.

For example a program could be designed to read in a text file, one line at a time, where each line in the file is supposed to start with a sequence followed by 3 atoms. Think customer information followed by an item number, item count and the item price. The program might be intended to add the item number to the end of the sequence and then compute the total charge and add that to the sequence and then store that sequence to a data base as a transaction.

That program make use of an included, company developed, generic file read function designed to read files containing text strings that represent euphoria sequences and text strings that represent individual atoms. That function could return a sequence of objects based on what was read (some sequences and some atoms).

Of course someone using this generic read function would want to verify the returned line items were the right type and order. And a program such as the one I propose might be designed to just stop if the input doesn't follow the right format (the concept of "do no more harm" and let a human figure out how to fix the problem).

So some "slick" programmer may have realized that the first append would abort if the first object in the line wasn't a sequence. So said programmer may have skipped the separate sequence test and depended on the append function working as documented.

Five years of running this program every hour 24x7x365 and only 3 aborts when the input file was corrupted one way or another and the company decides to stop using Euphoria 2.4 and move to the latest and greatest OpenEuphoria.

At this point, the previously working as designed program would be broken. It would no longer be detecting and aborting if the first line item wasn't a sequence. That is unless the programmer migrating this just happens to remember/realize that the append function was providing this sequence check and modifies the program to now do its own check instead.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu