[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] pkl: Return exception value instead of exit_status
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] pkl: Return exception value instead of exit_status |
Date: |
Wed, 12 Jan 2022 22:48:19 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h
> index dd164172..5712f819 100644
> --- a/libpoke/libpoke.h
> +++ b/libpoke/libpoke.h
> @@ -134,14 +134,14 @@ int pk_errno (pk_compiler pkc) LIBPOKE_API;
>
> /* Compile an execute a Poke program from the given file FILENAME.
>
> - If not NULL, *EXIT_STATUS is set to the status resulting from the
> - execution of the program.
> + If not NULL, *EXCEPTION is set to the unhandled exception which
> + happened during execution of program, or PK_NULL.
That is confusing. What about this:
---
If not NULL, *EXCEPTION is set to an exception value if the execution of
the program gets interrupted by an unhandled exception. Otherwise
*EXCEPTION is set to PK_NULL.
---
Similar in other doc strings...
> #define PVM_STATE_RESULT_VALUE(PVM) \
> (PVM_STATE_BACKING_FIELD (& (PVM)->pvm_state, result_value))
> +#define PVM_STATE_EXCEPTION_VALUE(PVM) \
> + (PVM_STATE_BACKING_FIELD (& (PVM)->pvm_state, exception_value))
I think "exception value" is too generic.
PVM_STATE_EXIT_EXCEPTION_VALUE? Same with other variables/fields/etc
like in:
> enum pvm_exit_code pvm_run (pvm vm,
> pvm_program program,
> - pvm_val *res);
> + pvm_val *res,
> + pvm_val *exception);
better exit_exception.
> diff --git a/poke/poke.c b/poke/poke.c
> index e317bf5d..1e44cb83 100644
> --- a/poke/poke.c
> +++ b/poke/poke.c
> @@ -432,11 +432,19 @@ parse_args_2 (int argc, char *argv[])
> pk_set_quiet_p (poke_compiler, 1);
> break;
> case 'l':
> - case LOAD_ARG:
> + case LOAD_ARG: {
> + pk_val exception;
> +
> if (pk_compile_file (poke_compiler, optarg,
> - NULL /* exit_status */) != PK_OK)
> - goto exit_success;
> - break;
> + &exception) != PK_OK
> + || exception != PK_NULL)
> + {
> + if (!poke_quiet_p)
> + pk_printf (_("unhandled exception while loading '%s'\n"),
> + optarg);
Please prefix the error with `error: ', and use the `name' and `msg'
fields of the exception. Something like:
pk_printf (_("error: unhandled % exception while loading '%s'\n"),
pk_struct_field_blahblah (exception, "name"),
optarg);
if (strcmp (pk_struct_field_blahblah (exception, "msg"), "") != 0)
pk_printf (_("error: %s\n"), msg);
> + goto exit_success;
> + }
> + } break;
> case 'c':
> case CMD_ARG:
> {