[m-dev.] for review: Underscore vars in pragma c code arguments

Andrew Bromage bromage at cs.mu.OZ.AU
Wed Aug 5 13:03:20 AEST 1998


G'day.

I diffed:

> > +place_pragma_output_args_in_regs([Arg | Args], [Reg | Regs], Outputs) -->
> >          { Arg = c_arg(Var, MaybeName, OrigType, _ArgInfo) },
> >          code_info__release_reg(Reg),
> >          code_info__set_var_location(Var, Reg),
> > +        { MaybeName = yes(Name) ->
> > +                (
> > +                        % If the first char of the variable is an
> > +                        % underscore, ignore it.
> > +
> > +                        string__first_char(Name, '_', _)
> > +                ->
> > +                        Outputs = Outputs0
> > +                ;
> > +                        Outputs = [pragma_c_output(Reg, OrigType, Name)
> > +                                        | Outputs0]
> > +                )
> >          ;
> > +                error("place_pragma_output_args_in_regs: unnamed arg")
> > +        },

Fergus Henderson wrote:

> I don't understand why the `MaybeName = no' case is
> treated differently than the case where the name starts
> with an underscore.

Which way should they be treated?  As an error or just ignored?

It's not an error to have an output argument which starts with an
underscore.  Just look at all the output io__state arguments in io.m.
The most sensible behaviour in this case seems to be just to ignore it.

Is it an error to have an output argument which is unnamed?  The
writer of original code thought so, and since I'm no expert on the
mechanics of pragma c_code generation I'm in no position to argue.

Cheers,
Andrew Bromage



More information about the developers mailing list