[m-rev.] for post-commit review: new options for querying the compiler

Julien Fischer jfischer at opturion.com
Thu Nov 13 17:16:58 AEDT 2014


On Thu, 13 Nov 2014, Zoltan Somogyi wrote:

> On Thu, 13 Nov 2014 16:16:00 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
>> Agreed, that predicate is becoming increasingly unwieldly.  I think
>> a better approach would be to have a separate type that represents
>> the different modes of operation of the compiler, e.g. something
>> like:
>>
>>        :- type mode_of_operation
>>  	--->	output_target_arch
>>  	;	output_class_dir
>>  	;	generate_file_mapping
>>  	;	compile_module
>>  	... etc etc
>>
>> and first convert the all the relevant command line options (and any
>> other required information) into a value of the above type.  If the
>> options conflict with each other we can then print an error message it
>> at that point, if not we can then switch on the new type (which would
>> replace the big if-then-else).
>
> One simple way to do that would be to have code that
> for each option that calls for such action, adds the
> corresponding mode_of_operation to a set. Then,
> at the end:
>
> - If the set is empty, do the default action.
>
> - If the set has one entry, do its action.
>
> - If the set has more than one entry, do the action
>  corresponding to the first after generating an error message
>  for all the others.

That was pretty much what I intended to do although I think the latter
case should just generate an error message and halt.  Also, just to be
clear, options like --help and --version should not count as modes of
operation and should retain their current precedence.

Cheers,
Julien.







>
> The priority among the modes_of_operation would thus be reflected
> in the order of the type's function symbols.
>
> Zoltan.
>
>



More information about the reviews mailing list