[m-rev.] for review: use enum to identify impl defined literals
Peter Wang
novalazy at gmail.com
Thu Apr 1 16:33:30 AEDT 2021
On Thu, 01 Apr 2021 14:01:16 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For review by anyone.
>
> Also, would people object if I made the code that converts int, float
> and string term functors to cons_ids actually check that they have
> no arguments? Catching mistakes such as 8("abc") only during
> typechecking generates not-all-that-helpful error messages
> that complain about 8 not being a function.
I don't see why not, though I don't remember making that mistake before.
> diff --git a/compiler/prog_data.m b/compiler/prog_data.m
> index c63db3e53..3ccc1b524 100644
> --- a/compiler/prog_data.m
> +++ b/compiler/prog_data.m
> @@ -205,6 +202,15 @@
> :- type lambda_eval_method
> ---> lambda_normal.
>
> +:- type impl_defined_const_kind
> + ---> idc_file % $file
> + ; idc_line % $line
> + ; idc_module % $module
> + ; idc_pred % $pred
> + ; idc_grade. % grade
$grade in the comment.
> diff --git a/compiler/superhomogeneous.m b/compiler/superhomogeneous.m
> index 2477e995f..c9340e631 100644
> --- a/compiler/superhomogeneous.m
> +++ b/compiler/superhomogeneous.m
...
> + ( if
> + ( Name = "line", IDCKind = idc_line
> + ; Name = "file", IDCKind = idc_file
> + ; Name = "module", IDCKind = idc_module
> + ; Name = "pred", IDCKind = idc_pred
> + ; Name = "grade", IDCKind = idc_grade
> + )
> + then
> + ConsId = impl_defined_const(IDCKind)
> + else
> + ErrorTerm = functor(Functor, ArgTerms, Context),
> + TermStr = describe_error_term(VarSet, ErrorTerm),
> + Pieces = [words("Error:"),
Whitespace at EOL.
That's fine, though.
Peter
More information about the reviews
mailing list