Put in skip list causing some -E- DXL: incorrect arguments for (if)

Hello,

I came accross some issue with if with the following sample code (interesting part start after comment "HERE!!":
 

Module m = current
AttrType at = find(m, "Good or bad")
 
if (null at) then{
  string codes[]={
      "good",
          "bad"}
  int values[] ={0,1}
  int colors[] ={realColor_Green,
                                 realColor_Red}
 
  string descs[]={
          "This is good",
          "This is bad"}
  string errmess = ""
  setRealColourOptionForTypes(true)
  at  = create("Good or bad", codes,values, colors,descs,errmess)
  
}
 
AttrDef ad = find(m,"Good or bad")
if (null ad) then{
                ad = create object type "Good or bad" attribute "Good or bad"
}
 
// HERE!!! ------------------------------
Object o = create m
 
bool b = true
Skip ooo = create
if b == true then
   put(ooo,o,o)
else
   o . "Good or bad" = "bad"
delete ooo

 


In this code I get the error -E- DXL: incorrect arguments for (if)

If I do the following then it works without error:

 

 

if b == true then
   o . "Good or bad" = "good"
else
   o . "Good or bad" = "bad"



Or if I do this,it also works without error



 

 

if b == true then
   put(ooo,o,o)
else{
   o . "Good or bad" = "bad"
}



That looks very strange, as some bug in DXL.

Any feedback welcome, I personally think that the only things to do is to file a bug report.

Vincent.



 


SystemAdmin - Wed Oct 26 04:25:38 EDT 2011

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
OurGuest - Wed Oct 26 07:58:04 EDT 2011

I think most people would just put: if(b){}

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Mathias Mamsch - Wed Oct 26 12:50:47 EDT 2011

That is really funny. It seems with that "put()" on the if statement any assignment in the else clause fails parsing ...

That code fails parsing:
 

Skip sk = create()
if (true) put(sk,0,0) else sk = null

 


That code does not fail parsing:

 

 

Skip sk = create()
if (true) put(sk,0,0) else { sk = null }



That code does also not fail parsing:



 

 

Skip sk = create()
if (true) put(sk,0,0) else print "Hallo" 
sk = null



So that is definitly a bug ;-) Maybe we should finally file all those DXL bugs. Maybe that is the straw that broke the camels back. We took it since version 5. Now we are fed up! ;-)

Regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
llandale - Wed Oct 26 13:20:19 EDT 2011

Mathias Mamsch - Wed Oct 26 12:50:47 EDT 2011

That is really funny. It seems with that "put()" on the if statement any assignment in the else clause fails parsing ...

That code fails parsing:
 

Skip sk = create()
if (true) put(sk,0,0) else sk = null

 


That code does not fail parsing:

 

 

Skip sk = create()
if (true) put(sk,0,0) else { sk = null }



That code does also not fail parsing:



 

 

Skip sk = create()
if (true) put(sk,0,0) else print "Hallo" 
sk = null



So that is definitly a bug ;-) Maybe we should finally file all those DXL bugs. Maybe that is the straw that broke the camels back. We took it since version 5. Now we are fed up! ;-)

Regards, Mathias



 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

I run into that pretty regularly forcing me to use braces around an else statement that "should" not need one. Just today:

if (canModify(in_obj)) //
then in_obj."Interface_SE-Analyst" = NameFull
else {g_CountFail++}

Never got around to narrowing down the exact causes, something Telelogic always insisted I do for them before they would even consider having development reject my suggestion there was a bug. Never occurred to me it was the "then" clause, now maybe I'll pay more attention. Like putting the braces around the "then" clause and seeing if that fixes it.

  • Louie

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Doug.Zawacki - Thu Oct 27 13:50:20 EDT 2011

llandale - Wed Oct 26 13:20:19 EDT 2011
I run into that pretty regularly forcing me to use braces around an else statement that "should" not need one. Just today:

if (canModify(in_obj)) //
then in_obj."Interface_SE-Analyst" = NameFull
else {g_CountFail++}

Never got around to narrowing down the exact causes, something Telelogic always insisted I do for them before they would even consider having development reject my suggestion there was a bug. Never occurred to me it was the "then" clause, now maybe I'll pay more attention. Like putting the braces around the "then" clause and seeing if that fixes it.

  • Louie

Interestingly enough...

This works

int i = 2, j = 2 
 
if i == j then j = 22

 


But this does not..

 

 

int i = 2, j = 2 
 
if i == j else j = 22

 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Doug.Zawacki - Thu Oct 27 13:56:18 EDT 2011

Doug.Zawacki - Thu Oct 27 13:50:20 EDT 2011

Interestingly enough...

This works

int i = 2, j = 2 
 
if i == j then j = 22

 


But this does not..

 

 

int i = 2, j = 2 
 
if i == j else j = 22

 

Ugh. Sorry...bad post..

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Doug.Zawacki - Thu Oct 27 14:01:04 EDT 2011

Doug.Zawacki - Thu Oct 27 13:56:18 EDT 2011
Ugh. Sorry...bad post..

Sorry, was reading the DXL help and my paste didn't work as expected.

The then form does not work with a condition that starts with a component in parenthesis, for example:
 

if (2 + 3) == 4 then print "no"

 


generates a syntax error.

 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Doug.Zawacki - Thu Oct 27 14:15:30 EDT 2011

Doug.Zawacki - Thu Oct 27 14:01:04 EDT 2011

Sorry, was reading the DXL help and my paste didn't work as expected.

The then form does not work with a condition that starts with a component in parenthesis, for example:
 

if (2 + 3) == 4 then print "no"

 


generates a syntax error.

 

Does anyone have a list of order of precendence evaluation?
I'm assuming the equal sign is why this doesn't work

int a
Skip sk = create()
if (true) put(sk,0,0) else a = 1

 


And there is no precendence evaluation needed in the statement below

 

 

Skip sk = create()
if (true) put(sk,0,0) else print "Hi"



Alas, I have learned to use paranthesis and brackets consistently to reduce frustration and confusion. It would seem to be a parsing error.



 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Doug.Zawacki - Thu Oct 27 14:37:40 EDT 2011

Doug.Zawacki - Thu Oct 27 14:15:30 EDT 2011

Does anyone have a list of order of precendence evaluation?
I'm assuming the equal sign is why this doesn't work

int a
Skip sk = create()
if (true) put(sk,0,0) else a = 1

 


And there is no precendence evaluation needed in the statement below

 

 

Skip sk = create()
if (true) put(sk,0,0) else print "Hi"



Alas, I have learned to use paranthesis and brackets consistently to reduce frustration and confusion. It would seem to be a parsing error.



 

ok. This is really messed up. I'm done looking at this...

This statement fails parsing...

int a = 0
Skip sk = create()
if (true) put(sk,0,0) else a = 1

 


This statement does not fail

 

 

string str = ""
Skip sk = create()
if (true) put(sk,0,0) else str = "x"



So, forget everything you've ever thought to be true Arrgghh!



 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
llandale - Thu Oct 27 15:53:28 EDT 2011

Doug.Zawacki - Thu Oct 27 14:37:40 EDT 2011

ok. This is really messed up. I'm done looking at this...

This statement fails parsing...

int a = 0
Skip sk = create()
if (true) put(sk,0,0) else a = 1

 


This statement does not fail

 

 

string str = ""
Skip sk = create()
if (true) put(sk,0,0) else str = "x"



So, forget everything you've ever thought to be true Arrgghh!



 

Yes, most of my trouble with this syntax is assocated with print statements and integer assignments as you have discovered. So I get the error, put it in braces, and move on. There are far bigger fish to "Arrgghh" about. And I do. In this case it won't help me to understand it since I'm going to continue to try to have nice pretty if-then-else blocks of single lines of code.

It helps a lot to accept DXL as "quirky" than to accuse it of being "buggy". Serenity ... change what you can ... bla bla bla.

  • Louie

"forget everything you've ever thought to be true". Got that advise years ago from my Zen Poker Master from Pluto who then told me what was really true; but I forgot.

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
PDU - Fri Oct 28 02:08:41 EDT 2011

llandale - Thu Oct 27 15:53:28 EDT 2011
Yes, most of my trouble with this syntax is assocated with print statements and integer assignments as you have discovered. So I get the error, put it in braces, and move on. There are far bigger fish to "Arrgghh" about. And I do. In this case it won't help me to understand it since I'm going to continue to try to have nice pretty if-then-else blocks of single lines of code.

It helps a lot to accept DXL as "quirky" than to accuse it of being "buggy". Serenity ... change what you can ... bla bla bla.

  • Louie

"forget everything you've ever thought to be true". Got that advise years ago from my Zen Poker Master from Pluto who then told me what was really true; but I forgot.

Hi all,

i think the solution is to use a style comparable to what is required in C (C++) developpement with quality constraints (see MISRA for example). In the example, use always brackets and embraces :

int a = 0
Skip sk = create()
if (true)
{
  put(sk, 0, 0)
}
else
{
  a = 1
}

 


Pierre

 

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
Tony_Goodman - Fri Oct 28 09:17:30 EDT 2011

PDU - Fri Oct 28 02:08:41 EDT 2011

Hi all,

i think the solution is to use a style comparable to what is required in C (C++) developpement with quality constraints (see MISRA for example). In the example, use always brackets and embraces :

int a = 0
Skip sk = create()
if (true)
{
  put(sk, 0, 0)
}
else
{
  a = 1
}

 


Pierre

 

I second what PDU said.

I ALWAYS use braces around every code block, no matter how small.

And I always use parentheses, even if they are "not required", especially after parameter-less functions.

These rules help make the code more readable and more robust.

I recommend everyone looks at the MISRA standards and takes on board good practice.

PS I gave up being surprised long ago. As Louie said, you learn the workarounds by heart and move on...

Tony Goodman, www.smartdxl.com

Re: Put in skip list causing some -E- DXL: incorrect arguments for (if)
llandale - Fri Oct 28 10:37:33 EDT 2011

Tony_Goodman - Fri Oct 28 09:17:30 EDT 2011
I second what PDU said.

I ALWAYS use braces around every code block, no matter how small.

And I always use parentheses, even if they are "not required", especially after parameter-less functions.

These rules help make the code more readable and more robust.

I recommend everyone looks at the MISRA standards and takes on board good practice.

PS I gave up being surprised long ago. As Louie said, you learn the workarounds by heart and move on...

Tony Goodman, www.smartdxl.com

I use the parens as it makes it easier to clarify what is and what is not a function, something the reader needs to know. And of course because I'm somewhat weak in this area and need to break it up visually and rely heavily on matching-pairs feature of Crimson.

But I think the 1st of the following is a lot easier to read than the 2nd.

int a = 0
Skip sk = create()
 
if (true) //
then put(sk, 0, 0)
else  a = 1
 
DoMoreWork()
//-------------------------
if (true)
{
  put(sk, 0, 0)
}
else
{
  a = 1
}
 
DoMoreWork()


I argue that visually its easier to tell that this represents simple processing. It also takes less vertical space, 3 lines instead of 8, which generally helps the reader overall.

But yes, it doesn't matter much one way or the other.

 

 

  • Louie