Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: rnd() as a constant expression

rnd() as a constant expression 25 May 2005 02:23 #6822

Hi all,
Can I use a rnd function with a const float value for initilizing
another const value, for example:
const float c := rnd(0.1); // VALID??

thanks!



Best Regards
Xiangdong Ji
Huawei Co. Ltd
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 08:15 #6823

Hi,

By default your example is invalid. The initial values of constants = shall be
decidable compile time. But calling any functions, including = built-in ones is
a run-time issue.

BR, Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: Wednesday, May 25, 2005 4:24 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: rnd() as a constant expression
>
>
> Hi all,
> Can I use a rnd function with a const float value for
>initilizing another const value, for example:
> const float c := rnd(0.1); // VALID??
>
> thanks!
>
>
>
> Best Regards
> Xiangdong Ji
> Huawei Co. Ltd
>
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 08:27 #6824

Hi,

Well, yes, except that the tool could be smart enough to figure out return
values of certain predefined functions already at translation time, much like it
could evaluate values of constant expressions at that time.

While personally I don't think that the example with rnd() is a good style for
use in constants, I would expect that certain tools would allow that and certain
tools would not, hence either save yourself from trouble and don't use such
constructs for portability reasons or push your tool vendor to support such
feature. :)

Best regards,
Alexey

Gy?rgy Réthy (IJ/ETH) wrote:

>Hi,
>
>By default your example is invalid. The initial values of constants
>shall be decidable compile time. But calling any functions, including built-i= n
ones is a run-time issue.
>
>BR, Gyorgy
>
>
>
>>
Original Message
>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>Sent: Wednesday, May 25, 2005 4:24 AM
>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>Subject: rnd() as a constant expression
>>
>>
>>Hi all,
>> Can I use a rnd function with a const float value for
>>initilizing another const value, for example:
>> const float c := rnd(0.1); // VALID??
>>
>>thanks!
>>
>>
>>
>>Best Regards
>>Xiangdong Ji
>>Huawei Co. Ltd
>>
>>
>>
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 09:03 #6825

Hi,

could, but this is would be an EXTENSION to the standard (therefore not = a
requirement toward tools). Hence writing a code with "const float c = :=
rnd(0.1);" may run on one tool and may not run on another tool. I = personally
doubt if any tool supports such an extension because as you = wrote this would
not be bad style without any real benefit.

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: Wednesday, May 25, 2005 10:27 AM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: rnd() as a constant expression
>
>
> Hi,
>
> Well, yes, except that the tool could be smart enough to figure out
>return values of certain predefined functions already at translation
>time, much like it could evaluate values of constant expressions at
>that time.
>
> While personally I don't think that the example with rnd() is a good
>style for use in constants, I would expect that certain tools would
>allow that and certain tools would not, hence either save yourself
>from trouble and don't use such constructs for portability reasons or
>push your tool vendor to support such feature. :)
>
> Best regards,
> Alexey
>
> Gy?rgy Réthy (IJ/ETH) wrote:
>
> >Hi,
> >
> >By default your example is invalid. The initial values of
> constants shall be decidable compile time. But calling any
> functions, including built-in ones is a run-time issue.
> >
> >BR, Gyorgy
> >
> >
> >
> >>
Original Message
> >>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
> >>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> >>Sent: Wednesday, May 25, 2005 4:24 AM
> >>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> >>Subject: rnd() as a constant expression
> >>
> >>
> >>Hi all,
> >> Can I use a rnd function with a const float value for
> >>initilizing another const value, for example:
> >> const float c := rnd(0.1); // VALID??
> >>
> >>thanks!
> >>
> >>
> >>
> >>Best Regards
> >>Xiangdong Ji
> >>Huawei Co. Ltd
> >>
> >>
> >>
>
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6826

Hello TTCN-3 users:

In the ETSI SIP test suite of version 2004-Nov-26 there is the following lines
in SIP_TypesAndConf.ttcn:

// %d09 ; US-ASCII HT, horizontal tab character
const charstring TAB := oct2str('09'O);

// %d13 ; US-ASCII CR, carriage return character
const charstring CR := oct2str('0D'O);

// %d10 ; US-ASCII LF, line feed character
const charstring LF := oct2str('0A'O);

It clearly indicates that at least ETSI is using in this case predefined
conversion functions of TTCN-3 to initialize charstring consts. So functions can
be used to inialize consts.

I guess at least some TTCN-3 predefined functions can be used with consts. I
guess there is not clear definition which functions can be used and which not.

Best regards,
Vesa-Matti

ETHGRY wrote:
> Hi,
>
> could, but this is would be an EXTENSION to
the standard (therefore not a requirement toward tools). Hence writing a code
with "const float c := rnd(0.1);" may run on one tool and may not run on
another tool. I personally doubt if any tool supports such an extension because
as you wrote this would be bad style without any real benefit.
>
> Gyorgy
>
>
>>
Original Message
>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>Sent: Wednesday, May 25, 2005 10:27 AM
>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>Subject: Re: rnd() as a constant expression
>>
>>
>>Hi,
>>
>>Well, yes, except that the tool could be smart enough to figure out
>>return values of certain predefined functions already at translation
>>time, much like it could evaluate values of constant expressions at
>>that time.
>>
>>While personally I don't think that the example with rnd() is a good
>>style for use in constants, I would expect that certain tools would
>>allow that and certain tools would not, hence either save yourself
>>from trouble and don't use such constructs for portability reasons or
>>push your tool vendor to support such feature. :)
>>
>>Best regards,
>>Alexey
>>
>>Gy?rgy Réthy (IJ/ETH) wrote:
>>
>>
>>>Hi,
>>>
>>>By default your example is invalid. The initial values of
>>
>>constants shall be decidable compile time. But calling any
>>functions, including built-in ones is a run-time issue.
>>
>>>BR, Gyorgy
>>>
>>>
>>>
>>>
>>>>
Original Message
>>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>>>Sent: Wednesday, May 25, 2005 4:24 AM
>>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>>>Subject: rnd() as a constant expression
>>>>
>>>>
>>>>Hi all,
>>>> Can I use a rnd function with a const float value for
>>>>initilizing another const value, for example:
>>>> const float c := rnd(0.1); // VALID??
>>>>
>>>>thanks!
>>>>
>>>>
>>>>
>>>>Best Regards
>>>>Xiangdong Ji
>>>>Huawei Co. Ltd
>>>>
>>>>
>>>>
>>
>
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6827

Hi,

the only contraint that is given in ETSI ES 201 873-1 V2.2.1 is the follo= wing
statement in the BNF:

STATIC SEMANTICS - SingleConstExpression shall not contain Variables or M= odule
parameters and shall resolve to a constant Value at compile time

From that point of view, the ETSI usage is correct (and also the rnd() mi= ght
be possible).

Best regards,
Stephan

Vesa-Matti Puro wrote:
> Hello TTCN-3 users:
>
> In the ETSI SIP test suite of version 2004-Nov-26 there is the
>following lines in SIP_TypesAndConf.ttcn:
>
> // %d09 ; US-ASCII HT, horizontal tab character
> const charstring TAB := oct2str('09'O);
>
> // %d13 ; US-ASCII CR, carriage return character
> const charstring CR := oct2str('0D'O);
>
> // %d10 ; US-ASCII LF, line feed character
> const charstring LF := oct2str('0A'O);
>
> It clearly indicates that at least ETSI is using in this case
>predefined conversion functions of TTCN-3 to initialize charstring
>consts. So functions can be used to inialize consts.
>
> I guess at least some TTCN-3 predefined functions can be used with
>consts. I guess there is not clear definition which functions can be
>used and which not.
>
> Best regards,
> Vesa-Matti
>
> ETHGRY wrote:
>
>>Hi,
>>
>>could, but this is would be an EXTENSION to
>
> the standard (therefore not a requirement toward tools). Hence
>writing a code with "const float c := rnd(0.1);" may run on one tool
>and may not run on another tool. I personally doubt if any tool
>supports such an extension because as you wrote this would be bad
>style without any real benefit.
>
>>Gyorgy
>>
>>
>>
>>>
Original Message
>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>>Sent: Wednesday, May 25, 2005 10:27 AM
>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>>Subject: Re: rnd() as a constant expression
>>>
>>>
>>>Hi,
>>>
>>>Well, yes, except that the tool could be smart enough to figure out
>>>return values of certain predefined functions already at translation
>>>time, much like it could evaluate values of constant expressions at
>>>that time.
>>>
>>>While personally I don't think that the example with rnd() is a good
>>>style for use in constants, I would expect that certain tools would
>>>allow that and certain tools would not, hence either save yourself
>>
>>>from trouble and don't use such constructs for portability reasons or
>>
>>>push your tool vendor to support such feature. :)
>>>
>>>Best regards,
>>>Alexey
>>>
>>>Gy?rgy Réthy (IJ/ETH) wrote:
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>By default your example is invalid. The initial values of
>>>
>>>constants shall be decidable compile time. But calling any
>>>functions, including built-in ones is a run-time issue.
>>>
>>>
>>>>BR, Gyorgy
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
Original Message
>>>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>>>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>>>>Sent: Wednesday, May 25, 2005 4:24 AM
>>>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>>>>Subject: rnd() as a constant expression
>>>>>
>>>>>
>>>>>Hi all,
>>>>> Can I use a rnd function with a const float value for
>>>>>initilizing another const value, for example:
>>>>> const float c := rnd(0.1); // VALID??
>>>>>
>>>>>thanks!
>>>>>
>>>>>
>>>>>
>>>>>Best Regards
>>>>>Xiangdong Ji
>>>>>Huawei Co. Ltd
>>>>>
>>>>>
>>>>>
>>>
>
>

--
Stephan Pietsch email This email address is being protected from spambots. You need JavaScript enabled to view it.
Testing Technologies IST GmbH web www.testingtech.de
Rosenthaler Str. 13 phone +49 30 726 19 19 11
10119 Berlin, Germany fax +49 30 726 19 19 20
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6828

Well, I agreed that using rnd as a constant expression is not a= good idea.
Furthermore,I think that most predefined funcitons can be used as= const if
their actual parameters are constant,including all Conversion
functions,lengthof= ,sizeof,regexp and substr.
thanks Gyorgy and Alexey:).



======= 2005-05-25 04:03:00=======

>Hi,
>
>could, but this is would be an EXTENSION to the standard (therefore not a requirement toward tools). Hence writing a code= with "const
float c := rnd(0.1);" may run on one tool and may= not run on another tool. I
personally doubt if any tool supports= such an extension because as you wrote
this would not be bad= style without any real benefit.
>
>Gyorgy
>
>>
Original Message
>> From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
>> [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>> Sent: Wednesday, May 25, 2005 10:27 AM
>> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>> Subject: Re: rnd() as a constant expression
>>
>>
>> Hi,
>>
>> Well, yes, except that the tool could be smart enough to figure out
>> return values of certain predefined functions already at translation
>> time, much like it could evaluate values of constant expressions at
>> that time.
>>
>> While personally I don't think that the example with rnd() is a good
>> style for use in constants, I would expect that certain tools would
>> allow that and certain tools would not, hence either save yourself
>> from trouble and don't use such constructs for portability reasons or
>> push your tool vendor to support such feature. :)
>>
>> Best regards,
>> Alexey
>>
>> Gy?rgy Réthy (IJ/ETH) wrote:
>>
>> >Hi,
>> >
>> >By default your example is invalid. The initial values of
>> constants shall be decidable compile time. But calling any functions,
>> including built-in ones is a run-time issue.
>> >
>> >BR, Gyorgy
>> >
>> >
>> >
>> >>
Original Message
>> >>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>> >>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>> >>Sent: Wednesday, May 25, 2005 4:24 AM
>> >>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>> >>Subject: rnd() as a constant expression
>> >>
>> >>
>> >>Hi all,
>> >> Can I use a rnd function with a const float value for
>> >>initilizing another const value,
>> >>for example:
>> >> const float c := rnd(0.1); // VALID??
>> >>
>> >>thanks!
>> >>
>> >>
>> >>
>> >>Best Regards
>> >>Xiangdong Ji
>> >>Huawei Co. Ltd
>> >>
>> >>
>> >>
>>

= = = = = = = = = = = = = = = = = = = =

Best Regards
Xiangdong Ji
Huawei Co. Ltd
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6829

Hi Vesa-Matti,
Would you kindly write a CR to clarify it?

======= 2005-05-25 12:36:00=======

>Hello TTCN-3 users:
>
>In the ETSI SIP test suite of version 2004-Nov-26 there is the
>following lines in SIP_TypesAndConf.ttcn:
>
> // d09 ; US-ASCII HT, horizontal tab character
> const charstring TAB := oct2str('09'O);
>
> // d13 ; US-ASCII CR, carriage return character
> const charstring CR := oct2str('0D'O);
>
> // d10 ; US-ASCII LF, line feed character
> const charstring LF := oct2str('0A'O);
>
>It clearly indicates that at least ETSI is using in this case
>predefined conversion functions of TTCN-3 to initialize charstring
>consts. So functions can be used to inialize consts.
>
>I guess at least some TTCN-3 predefined functions can be used with
>consts. I guess there is not clear definition which functions can be
>used and which not.
>
>Best regards,
>Vesa-Matti
>
>ETHGRY wrote:
>> Hi,
>>
>> could, but this is would be an EXTENSION to
>the standard (therefore not a requirement toward tools). Hence writing
>a code with "const float c := rnd(0.1);" may run on one tool and may
>not run on another tool. I personally doubt if any tool supports such
>an extension because as you wrote this would be bad style without any
>real benefit.
>>
>> Gyorgy
>>
>>
>>>
Original Message
>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members only
>>>[This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>>Sent: Wednesday, May 25, 2005 10:27 AM
>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>>Subject: Re: rnd() as a constant expression
>>>
>>>
>>>Hi,
>>>
>>>Well, yes, except that the tool could be smart enough to figure out
>>>return values of certain predefined functions already at translation
>>>time, much like it could evaluate values of constant expressions at
>>>that time.
>>>
>>>While personally I don't think that the example with rnd() is a good
>>>style for use in constants, I would expect that certain tools would
>>>allow that and certain tools would not, hence either save yourself
>>>from trouble and don't use such constructs for portability reasons or
>>>push your tool vendor to support such feature. :)
>>>
>>>Best regards,
>>>Alexey
>>>
>>>Gy?rgy Réthy (IJ/ETH) wrote:
>>>
>>>
>>>>Hi,
>>>>
>>>>By default your example is invalid. The initial values of
>>>
>>>constants shall be decidable compile time. But calling any functions,
>>>including built-in ones is a run-time issue.
>>>
>>>>BR, Gyorgy
>>>>
>>>>
>>>>
>>>>
>>>>>
Original Message
>>>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>>>>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
>>>>>Sent: Wednesday, May 25, 2005 4:24 AM
>>>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
>>>>>Subject: rnd() as a constant expression
>>>>>
>>>>>
>>>>>Hi all,
>>>>> Can I use a rnd function with a const float value for
>>>>>initilizing another const value,
>>>>>for example:
>>>>> const float c := rnd(0.1); // VALID??
>>>>>
>>>>>thanks!
>>>>>
>>>>>
>>>>>
>>>>>Best Regards
>>>>>Xiangdong Ji
>>>>>Huawei Co. Ltd
>>>>>
>>>>>
>>>>>
>>>
>>

= = = = = = = = = = = = = = = = = = = =

Best Regards
Xiangdong Ji
Huawei Co. Ltd
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6830

Hi,

I have to agree, not defined in detail (e.g.like a list of functions = allowed).
But changing the representation (i.e. type conversion) of a = literal value is
clearly different from calculating something.

Gyorgy

>
Original Message
> From: active_ttcn3 : mts stf133 ttcn version 3 - active members
>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> Sent: Wednesday, May 25, 2005 12:36 PM
> To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Subject: Re: rnd() as a constant expression
>
>
> Hello TTCN-3 users:
>
> In the ETSI SIP test suite of version 2004-Nov-26 there is the
>following lines in SIP_TypesAndConf.ttcn:
>
> // %d09 ; US-ASCII HT, horizontal tab character
> const charstring TAB := oct2str('09'O);
>
> // %d13 ; US-ASCII CR, carriage return character
> const charstring CR := oct2str('0D'O);
>
> // %d10 ; US-ASCII LF, line feed character
> const charstring LF := oct2str('0A'O);
>
> It clearly indicates that at least ETSI is using in this case
>predefined conversion functions of TTCN-3 to initialize charstring
>consts. So functions can be used to inialize consts.
>
> I guess at least some TTCN-3 predefined functions can be used with
>consts. I guess there is not clear definition which functions can be
>used and which not.
>
> Best regards,
> Vesa-Matti
>
> ETHGRY wrote:
> > Hi,
> >
> > could, but this is would be an EXTENSION to
> the standard (therefore not a requirement toward tools). Hence writing
> a code with "const float c := rnd(0.1);" may run on one tool and may
> not run on another tool. I personally doubt if any tool supports such
> an extension because as you wrote this would be bad style without any
> real benefit.
> >
> > Gyorgy
> >
> >
> >>
Original Message
> >>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
> >>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> >>Sent: Wednesday, May 25, 2005 10:27 AM
> >>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> >>Subject: Re: rnd() as a constant expression
> >>
> >>
> >>Hi,
> >>
> >>Well, yes, except that the tool could be smart enough to figure out
> >>return values of certain predefined functions already at translation
> >>time, much like it could evaluate values of constant expressions at
> >>that time.
> >>
> >>While personally I don't think that the example with rnd() is a good
> >>style for use in constants, I would expect that certain tools would
> >>allow that and certain tools would not, hence either save yourself
> >>from trouble and don't use such constructs for portability
> reasons or
> >>push your tool vendor to support such feature. :)
> >>
> >>Best regards,
> >>Alexey
> >>
> >>Gy?rgy Réthy (IJ/ETH) wrote:
> >>
> >>
> >>>Hi,
> >>>
> >>>By default your example is invalid. The initial values of
> >>
> >>constants shall be decidable compile time. But calling any
> >>functions, including built-in ones is a run-time issue.
> >>
> >>>BR, Gyorgy
> >>>
> >>>
> >>>
> >>>
> >>>>
Original Message
> >>>>From: active_ttcn3 : mts stf133 ttcn version 3 - active members
> >>>>only [This email address is being protected from spambots. You need JavaScript enabled to view it.]
> >>>>Sent: Wednesday, May 25, 2005 4:24 AM
> >>>>To: This email address is being protected from spambots. You need JavaScript enabled to view it.
> >>>>Subject: rnd() as a constant expression
> >>>>
> >>>>
> >>>>Hi all,
> >>>> Can I use a rnd function with a const float value for
> >>>>initilizing another const value, for example:
> >>>> const float c := rnd(0.1); // VALID??
> >>>>
> >>>>thanks!
> >>>>
> >>>>
> >>>>
> >>>>Best Regards
> >>>>Xiangdong Ji
> >>>>Huawei Co. Ltd
> >>>>
> >>>>
> >>>>
> >>
> >
>
The administrator has disabled public write access.

rnd() as a constant expression 25 May 2005 10:36 #6831

>
Ursprüngliche Nachricht
> Von: active_ttcn3 : mts stf133 ttcn version 3 - active members
>only [This email address is being protected from spambots. You need JavaScript enabled to view it.] Im Auftrag von Vesa-Matti Puro
> Gesendet: Mittwoch, 25. Mai 2005 12:36
> An: This email address is being protected from spambots. You need JavaScript enabled to view it.
> Betreff: Re: rnd() as a constant expression
>
> Hello TTCN-3 users:
>
> In the ETSI SIP test suite of version 2004-Nov-26 there is the
>following lines in SIP_TypesAndConf.ttcn:
>
> // %d09 ; US-ASCII HT, horizontal tab character
> const charstring TAB := oct2str('09'O);
>
> // %d13 ; US-ASCII CR, carriage return character
> const charstring CR := oct2str('0D'O);
>
> // %d10 ; US-ASCII LF, line feed character
> const charstring LF := oct2str('0A'O);
>
> It clearly indicates that at least ETSI is using in this case
>predefined conversion functions of TTCN-3 to initialize charstring
>consts. So functions can be used to inialize consts.


This is consistent with Tau/Tester's support for constant = initialization,
which allows these conversion functions to be used in = this context. Rnd is not
allowed, though. Clearly, this is correct for = rnd(), which is not constant but
changes its value for each call. For rnd(double) the situation is different, of course, so one could think = about
allowing rnd(double) to be used in constant initialization. = Whether this is
good style? - I tend to think no.

Best regards

Stephan
The administrator has disabled public write access.
  • Page:
  • 1

FacebookTwitterGoogle BookmarksRedditNewsvineTechnoratiLinkedin