access current input file name and line number with all_input_lines() #36

Open
opened 2026-02-04 12:01:40 +01:00 by ni · 1 comment
ni commented 2026-02-04 12:01:40 +01:00 (Migrated from git.w21.org)

Like $. in Perl, current_input_lineno shall hold the current line number of the current input file when all_input_lines() is running; current_input_fname shall hold the current input file name.

As I have no explicit context of the running generator (and don't want to complicate its use), these must be global variables in the jpylib (or y) name space. That may not be appropriate in some applications, e.g. if one generator is called while another one is active at the same time; in these cases, other generators must be used. Still, this may be of benefit to most use cases.

Like `$.` in Perl, `current_input_lineno` shall hold the current line number of the current input file when all_input_lines() is running; `current_input_fname` shall hold the current input file name. As I have no explicit context of the running generator (and don't want to complicate its use), these must be global variables in the `jpylib` (or `y`) name space. That may not be appropriate in some applications, e.g. if one generator is called while another one is active at the same time; in these cases, other generators must be used. Still, this may be of benefit to most use cases.
ni commented 2026-02-04 12:01:40 +01:00 (Migrated from git.w21.org)

assigned to @ni

assigned to @ni
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
w21/jpylib#36
No description provided.