? current-line depreciated

Started by nigelbrown, November 18, 2003, 08:20:42 PM

Previous topic - Next topic

nigelbrown

In the newlisp docs (manual v7.3.3) it says about current-line:

current-line

syntax: (current-line) deprecated use $0



However, $0 is used as a return variable from regex -

is the "deprecated use $0" a documentation error?

Regards

Nigel

Lutz

#1
$0, $1 and so forth are system variables used first in functions using regular expressions, but I want to expand the usage to other very few areas where it makes sense.



I works already in: (replace elmnt list), which is a version of 'replace' which works on lists without regular expressions. In this case the replace count is in $0.



$0 for current-line is in the doc, but I forgot to implement it. I sometimes do the documentation before the code ;-) . It will work in 7.3.8 .





Lutz

nigelbrown

#2
My concern was that I'm doing a little awk-like implementation in newlisp and am using both read-line and multiple regex (on current-line or part thereof) mixed in the code.

I currently retrieve (current-line) a number of times per line read and apply regex various ways (the way awk steps through applying its pattern rules over and cver to the one line).

I couldn't see how having $0 for both current-line and regex use would work in that situation and am quite happy that $0 is used with regex and that current-line is not depreciated - perhaps it should stay that way.



I can see the logic for reusing a concept like $0 across various functions to aid programming but if it is used by functions that may be sprinkled through the one code fragment the nature of its current value becomes problematical (and could vary in nature depending on the program path taken to get to a particular point).



I would vote for keeping (current-line) as is.



Regards

Nigel



PS re manual typos - the syntax definition of (single ... reads (sin ... in the manual I have.

Lutz

#3
I think we keep it then like it is for now (will change docs)



Lutz