Re: What is process_lines? and general complaint on the new manual
- Posted by ChrisB (moderator) Jan 19, 2011
- 2130 views
Hi
It used to be that all functions required a return value, or else an error would be thrown. Now, when you call a function, you don't need a return value, so
function foo() return 1 end function integer x x = foo() -- ok eu 3.xx, and 4.xx foo() --throws and error with eu3, but is ok with 4
Kind of makes the procedure redundant, makes no real difference with speed (AFAIK), and seems to be being maintained for backwards compatability.
On the subject of the manual, I find it readable, and clear (see the section where it says 'Returns :'), I think the problem is with the explanation of the function itself. I would probably avoid it myself (personally), as, for me, it reduces clarity of the code (others may / will disagree). Perhaps a 'simpleton' (stress for the likes of me too!) explanation would be of benefit. To me, the example is not of much help.
-- Format each supplied line according to the format pattern supplied as well. function show(sequence aLine, integer line_no, object data) writefln( data[1], {line_no, aLine}) if data[2] > 0 and line_no = data[2] then return 1 else return 0 end if end function -- Show the first 20 lines. process_lines("sample.txt", routine_id("show"), {"[1z:4] : [2]", 20}) --^^^^^^^^^^^^^^^^^^ a better explanation of this
The function show(), seems to be writing to a file, rather than showing it, and where does the 'first 20 lines' come from?
Chris