Re: void pointer



Nick Keighley <nick_keighley_nospam@xxxxxxxxxxx> writes:

On 2 Oct, 12:27, Ben Bacarisse <ben.use...@xxxxxxxxx> wrote:
Nick Keighley <nick_keighley_nos...@xxxxxxxxxxx> writes:
On 2 Oct, 10:45, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
Nick Keighley said:

Is this a strictly conforming program?

int main (void)
{
    int fortran = 1;
    int asm = 2;
    return 0;
}

Yes.

if it is then certain common extensions will break it.

Not necessarily. An implementation that offers fortran and asm as keywords
might nevertheless be "bright" enough to recognise such situations and
deal with them appropriately.

I think your "bright enough" compiler would be a candidate for
passing the Turing test.
<snip>
 Do you mean that the only way to disambiguate uses of a
keyword that might also be an identifier must use AI rather than
convention parsing techniques?

pretty close to, yes


If so, I disagree.  It is possible to add a keyword to C that does not
interfere with it use as an identifier if the designer makes the right
language choices.

yes, but we are talking about the "Common Extensions" part of the
standard. Richard Heathfield argued that it was legitimate to cast
a function pointer to an object pointer because this appeared in
Common Extensions (which *I* call Section F.5). I argue that CEs
are not allowed in a conforming compiler precisly becuase it breaks
things. asm and fortran are keywords listed in CE.

I had missed that you were assuming a particular syntax. Section J.5
talks about fortran being a "keyword" and the asm(<string literal>);
syntax. The asm syntax looks like a function call so I can't see how
it can "break things". Not unless you also say that open() or fork()
are not allowed in a conforming compiler.

 I am not talking about simply picking a keyword
that is in the implementation name-space (i.e. _Fortran).  It is
possible to design the syntax so that 'fortran' is a legal identifier
but also acts like a keyword in the right context.  I am not sure it
is a good idea, but it is possible.

are you sure.

Am I sure that it is possible? Yes (if I get to define all the terms!).

[I snipped your examples because they seemed to be using a particular
bad design as an argument against a general point.]

I thought my examples quite relevent. I think it is difficult
for fortran and asm to be both language words and identifiers.
Not the standard doesn't expect you to do it with other keywords.

We may be talking at cross purposes or at least be having a
definitional disagreement. If you make fortran a keyword in the
traditional sense then it is forbidden as an identifier. I did not
think this is what you meant because no amount of cleverness in the
compiler can alter this. The trick is to define the syntax so that
you can tell how the word is being used.

int main (int long, char *char[])
{
int int;
int return = 0;
for (int = 0; int < long; int++)
fortran();
return return;
}

Well, I won't snip it this time, but I don't see how a single example
helps make a case that to parse this requires AI-like cleverness in
the compiler.

--
Ben.
.



Relevant Pages

  • Re: A __getattr__ for class methods?
    ... or am I trying to mirror a functionality that Python simply does ... I'm not sure that the way you tackled this is the good approach: while it's quite flexible as far as the search criteria go, it'll require less than obvious code to match keywords and values, will lead to somewhat verbose syntax, and the syntax itself is unforgiving, brittle and not really pythonic. ... As you probably know, Python has a good support for keyword args, allowing you to fill your arguments out of order. ... But **kwargs goes beyond the regular explicit keyword arguments: when specified, **kwargs is a dict populated with the implicit keyword arguments, the ones you haven't specified in the argument tuple of your method. ...
    (comp.lang.python)
  • Re: fortran 200X proposal: "use none" counterpart to "implicit none"
    ... having lots of special cases placing high burden on Fortran ... On the USE statement you can specify the module nature ... to have a "NONE" keyword seems like a better idea. ...
    (comp.lang.fortran)
  • Re: Jython inherit from Java class
    ... Compiling .java to .class... ... 'assert' is a keyword, and may not be used as an identifier ... release 1.5, 'enum' is a keyword, and may not be used as an identifier ...
    (comp.lang.python)
  • Re: Lisp at sexps length
    ... as Thomas points out. ... in the context of the data structure that is being built for the ... it is prefix syntax because the description comes ... > Common Lisp require that keyword argument markers be keyword SYMBOLS. ...
    (comp.lang.lisp)
  • Re: Working on new language
    ... I really do like self documenting syntax like this, the only thing is it can ... to select specific options that the compiler enforces. ... So apart from the "so" keyword mentioned below I require ... Keyword: 10 pow: 2 ...
    (comp.lang.misc)