Jump to page: 1 2
Thread overview
(a) & b parsed as cast expr!
Jan 13, 2005
bug
Jan 13, 2005
Stewart Gordon
Jan 16, 2005
Walter
Jan 16, 2005
bug
Jan 20, 2005
Walter
Jan 22, 2005
Ivan Senji
Jan 24, 2005
Stewart Gordon
Jan 24, 2005
Ivan Senji
Jan 24, 2005
Stewart Gordon
Jan 24, 2005
Ivan Senji
Jan 16, 2005
bug
January 13, 2005
======================================== op.d ===
int main(char[][] args)
{
int a, b, c;

c = (a) & b;  // a & b works, b & (a) works
return 0;
}
======================================== op.d ===

$ dmd op.d
op.d(5): C style cast deprecated, use cast(a)(#b)



January 13, 2005
bug@d.com wrote:
> ======================================== op.d ===
> int main(char[][] args)
> {
> int a, b, c;
> 
> c = (a) & b;  // a & b works, b & (a) works
> return 0;
> }
> ======================================== op.d ===
> 
> $ dmd op.d
> op.d(5): C style cast deprecated, use cast(a)(#b)

Been mentioned a few times.  It's just a limitation of context-free parsing coupled with a grammar that isn't quite made for it.  Once C-style casts finally get removed from the language, it'll work.

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
January 16, 2005
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:cs60b2$2j0o$1@digitaldaemon.com...
> bug@d.com wrote:
> > ======================================== op.d ===
> > int main(char[][] args)
> > {
> > int a, b, c;
> >
> > c = (a) & b;  // a & b works, b & (a) works
> > return 0;
> > }
> > ======================================== op.d ===
> >
> > $ dmd op.d
> > op.d(5): C style cast deprecated, use cast(a)(#b)
>
> Been mentioned a few times.  It's just a limitation of context-free parsing coupled with a grammar that isn't quite made for it.  Once C-style casts finally get removed from the language, it'll work.

True. I should also point out that while putting pointless parentheses around expressions is common in C (because of macro argument expansions), they are unnecessary in D, so this bug shouldn't cause significant problems.


January 16, 2005
In article <cscvki$10av$1@digitaldaemon.com>, Walter says...
>
>
>"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:cs60b2$2j0o$1@digitaldaemon.com...
>> bug@d.com wrote:
>> > ======================================== op.d ===
>> > int main(char[][] args)
>> > {
>> > int a, b, c;
>> >
>> > c = (a) & b;  // a & b works, b & (a) works
>> > return 0;
>> > }
>> > ======================================== op.d ===
>> >
>> > $ dmd op.d
>> > op.d(5): C style cast deprecated, use cast(a)(#b)
>>
>> Been mentioned a few times.  It's just a limitation of context-free parsing coupled with a grammar that isn't quite made for it.  Once C-style casts finally get removed from the language, it'll work.
>
>True. I should also point out that while putting pointless parentheses around expressions is common in C (because of macro argument expansions), they are unnecessary in D, so this bug shouldn't cause significant problems.

The code actually is generated by a tool :-)

D compiler should be friendly with code-generation tools, to make D more popular.


January 16, 2005
Walter wrote:

>>Been mentioned a few times.  It's just a limitation of context-free
>>parsing coupled with a grammar that isn't quite made for it.  Once
>>C-style casts finally get removed from the language, it'll work.
> 
> True. I should also point out that while putting pointless parentheses
> around expressions is common in C (because of macro argument expansions),
> they are unnecessary in D, so this bug shouldn't cause significant problems.

Some people put extra parenthesis to make later maintenance easier,
just as they put extra braces on the if and else statement blocks...

But that's really besides the point. D is not source-compatible with C,
so the code-generator tool mentioned just seems to be broken... :-)


If there is a more complex generator than the "a,b,c" example lurking
behind-the-scenes, it would be interesting to see some real code...

Otherwise, just drop the parens. Just like with functions: (void) => ()

--anders
January 16, 2005
In article <csdv2i$1vhh$1@digitaldaemon.com>, =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= says...
>
>Walter wrote:
>
>>>Been mentioned a few times.  It's just a limitation of context-free parsing coupled with a grammar that isn't quite made for it.  Once C-style casts finally get removed from the language, it'll work.
>> 
>> True. I should also point out that while putting pointless parentheses around expressions is common in C (because of macro argument expansions), they are unnecessary in D, so this bug shouldn't cause significant problems.
>
>Some people put extra parenthesis to make later maintenance easier, just as they put extra braces on the if and else statement blocks...
>
>But that's really besides the point. D is not source-compatible with C, so the code-generator tool mentioned just seems to be broken... :-)
>


No one mentioned that the tool is a dedicated C tool.

There's only one question here: puting extra parenthesis around 'a' is valid D syntax or not.

If it is, then the DMD compiler should be fixed.  Otherwise, the tool should be fixed.

Make simple things simple.


>
>If there is a more complex generator than the "a,b,c" example lurking behind-the-scenes, it would be interesting to see some real code...
>
>Otherwise, just drop the parens. Just like with functions: (void) => ()
>
>--anders


January 20, 2005
<bug@d.com> wrote in message news:csd25m$12f6$1@digitaldaemon.com...
> >True. I should also point out that while putting pointless parentheses around expressions is common in C (because of macro argument expansions), they are unnecessary in D, so this bug shouldn't cause significant
problems.
>
> The code actually is generated by a tool :-)

I hadn't thought of that. You can make it work by adding a unary +, as in
(+p).

> D compiler should be friendly with code-generation tools, to make D more popular.

I agree.


January 22, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:csn5bj$157d$3@digitaldaemon.com...
>
> <bug@d.com> wrote in message news:csd25m$12f6$1@digitaldaemon.com...
> > >True. I should also point out that while putting pointless parentheses around expressions is common in C (because of macro argument
expansions),
> > >they are unnecessary in D, so this bug shouldn't cause significant
> problems.
> >
> > The code actually is generated by a tool :-)
>
> I hadn't thought of that. You can make it work by adding a unary +, as in
> (+p).

That is a great idea, my tool also generates a code that looks like this and
this will
fix it. :)
But i hope that removing c-style casts will fix this? It would be better to
remove
c-cast code sooner to have more time to fix bugs that might be caused by
removing it.

>
> > D compiler should be friendly with code-generation tools, to make D more popular.
>
> I agree.
>
>


January 24, 2005
Ivan Senji wrote:
<snip>
> But i hope that removing c-style casts will fix this? It would be
> better to remove c-cast code sooner to have more time to fix bugs
> that might be caused by removing it.
<snip>

Really?  Do that many people compile in deprecated mode for everyday purposes?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
January 24, 2005
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:ct2mrm$qoq$1@digitaldaemon.com...
> Ivan Senji wrote:
> <snip>
> > But i hope that removing c-style casts will fix this? It would be better to remove c-cast code sooner to have more time to fix bugs that might be caused by removing it.
> <snip>
>
> Really?  Do that many people compile in deprecated mode for everyday purposes?

I don't! But maybe you didn't understand me (and i can't blame you because
of
my English): I wanted to write: In the compiler there is code that parses
c-casts
and causes wrong messages about c cast when what you are trying to do has
nothing to
do with casting.
Like in:
int abc,def;
def = (abc) + 2;

Now it will probbably be fixed by removing c-casts code, and enable the
above
code to be parsed as an assignement, but removing that code could also
result
in new bugs. And we don't need them :)

>
> Stewart.
>
> --
> My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.


« First   ‹ Prev
1 2