[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Gawk debug command 'eval'
From: |
arnold |
Subject: |
Re: [bug-gawk] Gawk debug command 'eval' |
Date: |
Fri, 15 Feb 2019 03:54:05 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hello. Thanks for the note.
The debugger was done by someone who left the development team a few
years ago, and I am less familiar with that part of the code base.
That said, I took a quick look, and return from inside code being
run by eval is indeed disallowed. I am not sure why; I suspect it's
to keep someone from trying to run 'return' when not in a function,
but I think it also has something to do with how eval is implemented.
It's essentially done as a function call from within the current
context, so return would cause the eval to finish, and not a
called function.
I will document this limitation, and make a note to see if it can
be worked around at some point in the future.
By the way, your version appears to be unofficial; did you build
it off master? I generally recommend using just the released versions.
Thanks,
Arnold
Lothar Langer <address@hidden> wrote:
> Hi,
>
> i didn't read anything in the 'Gawk User's Guide' that it is not
> possible to evaluate user defined functions with the command 'eval' in
> the debugger.
>
> Example:
>
> function isnumeric(x) {
> return (length(x) && x == x+0)
> }
>
> ...
>
> gawk> eval "print isnumeric(\"hello\")"
> error: `return' not allowed in current context; statement ignored
>
> ... but ...
>
> gawk> eval "print length(\"hello\")"
> 5
>
> ... which is expected ...
>
> My version is:
> GNU Awk 4.2.60, API: 2.0