[m-dev.] fix for bytecode generator

Bert Thompson aet at cs.mu.oz.au
Thu Mar 20 11:21:40 AEDT 1997


|Bert Thompson, you wrote:
|> 
|> [Simone wrote:] 
|> |so I don't think the change
|> |would actually save much.
|> 
|> You're right. It doesn't save much at all. 
|[...]
|> Miniscule though the saving may be, [...]
|
|The savings would not be miniscule, they would be negative.

Incorrect. You address the wrong point. See below.

|If you want characters to be less of a special case than they are now,
|then the right way to do it would be to make character literals
|quantified (i.e. mercury_builtin:'a', mercury_builtin:'b', ...,
|or perhaps char:'a', char:'b', ...).  However, doing this would
|require some special-case coding (catch 22), and they would still have
|to treated as a special case in exactly the same places that they're
|already treated specially.  So I don't think this would be worthwhile.

I didn't propose to make characters any less of a special case.
Read my suggestion again and the rationale below.

Now let's stop beating this dead horse.

Bert

--------------------
Gday Simon,

The change looks great. 

One observation however...

|+			% Everything other than characters should
|+			% be module qualified.
|+			Functor = unqualified(FunctorName),
|+			string__to_char_list(FunctorName, FunctorList),
|+			( FunctorList = [Char] ->
|+				ByteConsId = char_const(Char)
|+			;	
|+				error("bytecode_gen__map_cons_id: unqualified c
|ons_id is not a char_const")
|+			)
| 		;

Is it possible to avoid the test "FunctorList = [Char]"  by changing
the declaration of sym_name prog_data.m to:

:- type sym_name 	---->	unqualified(string)	% Can remove?
			;	qualified(module_specifier, string)
			;	char_const(char).	% Added

and the above code to:

			% Everything other than characters should
			% be module qualified.
			Functor = char_const(Char),
			ByteConsId = char_const(Char)
		;

This simplifies the code, but means changing other code that uses
`unqualified(string)' to represent a char constant.

Advantages of this are:
	- The typechecker prevents us from using an invalid
	  data representation such as unqualified("Not a single char").
	- No longer need tests that `unqualified(string)' represents
	  a character constant.
	- There's one less place where the compiler can fail with
	  a runtime error.

Bert



More information about the developers mailing list