![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: intOf(Date d) != (intOf(Date d)) Topic Summary: intOf(Date d) handling is inconsistent Created On: 15-Sep-2005 18:55 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
When working with dates, intOf returns different string values, depending upon whether or not it has parentheses around it. See the example program below:
Date d = "04/28/05 15:39:05" print intOf(d) "\n" print (intOf(d)) "\n" The output of this is: 4 1114727945 intOf(d) treats d as if it were a string (intOf(d)) treats d as a date This difference should be documented (or fixed? bug or feature?). Note that this is in DOORS 7.1. ------------------------- Shawn Stepper shawn.e.stepper@wellsfargo.com |
|
![]() |
|
![]() |
|
Shawn,
I consider it a flaw, and believe it should be fixed. The flaw seems to be in "binary op (concatenation)" for functions with integer return values. Another example: print random( 100 ) "\n" print ( random( 100 ) ) "\n" Results: 0.000009100 *wrong* 35 *correct* The extra parenthesis typecasts the integer function correctly, and avoids the bug. ------------------------- Michael Sutherland michael@galactic-solutions.com http://galactic-solutions.com |
|
![]() |
|
![]() |
|
I think its more restrictive than Sutherland suggests. This issue comes up when using the binary op inside some other function like "print" or "if".
Date d = "04/28/05 15:39:05" int a =intOf(d) int b = (intOf(d)) print a "\t" b "\n" // prints correctly and the same: 1114720745 1114720745 But yes, routinely use parenthesis when dealing with integer operations in call parameters. - Louie |
|
![]() |
|
![]() |
|
Parentheses around the parameter to a single parameter function are not required and seem to be ignored by the interpreter. Hence the problem here is caused by the parameter being cast to a string by the concatenation of "\n".
The following is a well known feature: If you run print upper("hello") "world\n" you might expect to get "HELLO world" as the output. However, what you actually get is "HELLO WORLD". The string concatenation has higher precedence than the function call, so the string are concatenated before being passed to the function. ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
I had thought the problem was localized to system built in functions. But confirming your observation:
string Upper(string InString) { return(upper(InString)) } string Results = upper ("hello ") "world\n" print "Print1\t" upper("hello ") "world\n" print "Print2\t" (upper "hello ') "world\n" print "upper\t" Results Results = Upper("hello ") "world\n" print "Upper\t" Results Notice the 2nd print works. Use of both "upper" and "Upper" behave the same. Sounds like we should initiate a trouble report suggesting that the interpreter does NOT ignore the parenthesis for single-parameter functions. - Louie |
|
![]() |
|
![]() |
|
Parentheses being ignored is a major problem. I didn't realize the problem was that bad!
print upper("hello") "world\n" should DEFINITELY produce: HELLO world This also explains the problem that I initially reported. Expanding on my first post: Date d = "04/28/05 15:39:05" print intOf(d) "\n" print intOf d "\n" print intOf(d "\n") print (intOf(d)) "\n" Produces: 4 4 4 1114727945 The only reason [print (intOf(d)) "\n"] produces the correct result is because the extra () force precedence to be interpreted CORRECTLY. But they should not be necessary. So, anyone from Telelogic reading this? This is a serious defect! ------------------------- Shawn Stepper shawn.e.stepper@wellsfargo.com Edited: 30-Sep-2005 at 01:28 by Shawn Stepper |
|
![]() |
Telelogic DOORS
» Defect/Issue Tracking
»
intOf(Date d) != (intOf(Date d))
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.