none
[MS-VBAL] Constant declarations and minor typos RRS feed

  • Question

  • In section 5.2.3.2 there is a syntax ``const-as-clause'' defined as ``"as" BUILTIN-TYPE''. However fixed length strings (which are not BUILTIN-TYPE) are allowed and properly coerced:

    Const myConst As String * 1 = "12"

    Now ``myConst'' has value "1". That works fine in Excel 2007 (in case of both: module constants as well as procedures' local constants).

    In section 6.1.2.7.1.5 IsError, Runtime Semantics: ``IsEmpty returns...''. Should be ``IsError returns...''.

    In section 6.1.2.7.1.8 IsNumeric, Runtime Semantics: there is no ``Boolean'' for which the function returns ``true'' as well.

    -- best regards

    Saturday, May 9, 2020 12:03 AM

Answers

  • Hi Cezary

    Request send to fix the following typo in [MS-VBAL]

    In section 6.1.2.7.1.5 IsError, Runtime Semantics: ``IsEmpty returns...''. Should be ``IsError returns...''.

    In section 6.1.2.7.1.8 IsNumeric, Runtime Semantics: there is no mentioned of  ``Boolean'' for which the function returns ``true'' as well.

    Thank you for reporting the issues to Microsoft Protocol Open Specifications Support.


    HungChun Yu (MSFT)

    Wednesday, May 13, 2020 5:04 PM
  • Hi Cezary

    1. Following construct is still valid with Excel 2016, where myConst = "1"

    Const myConst As String * 1 = "12"

    2. It does have to do with string type definition. Fixed-length-string is still considered a string type. Hence it's will be part of of "BULTIN-TYPE", therefor there will be no change to const-as-clause at this time.

    We do plan to expand section 2.1 Data Values and Value Types to include definition of fixed-length-string. Hopefully, this helped answer your question.


    HungChun Yu (MSFT)


    Friday, June 12, 2020 4:41 PM

All replies

  • Hi Cezary,

    Thank you for your question. We will follow up on the typos.

    Thanks,


    Jeff McCashland | Microsoft Protocols Open Specifications Team

    Saturday, May 9, 2020 2:33 AM
    Moderator
  • Hi Cezary,

    I have questions on a couple of your statements:

    For Section 5.2.3.2: String is actually a BUILTIN-TYPE. Section 3.3.5.3 defines BUILTIN-TYPE as:

    BUILTIN-TYPE = reserved-type-identifier /  ("[" reserved-type-identifier "]") / "object" / "[object]" 

    Section 3.3.5.2 defines reserved-type-identifier as:

    reserved-type-identifier = "Boolean" / "Byte" / "Currency" / "Date" / "Double" /  "Integer" / "Long" / "LongLong" / "LongPtr" / "Single" / "String" / "Variant" 

    So there is no inconsistency in section 5.2.3.2. Did I understand the question correctly?

    For section 6.1.2.7.1.8, you mentioned: "there is no ``Boolean'' for which the function returns ``true'' as well"

    I do not understand this statement. Can you add more detail, phrase it differently, or give an example?

    Thanks,


    Jeff McCashland | Microsoft Protocols Open Specifications Team


    Monday, May 11, 2020 9:33 PM
    Moderator
  • Hi Cezary

    You mentioned that fixed length strings are not BUILDIN-Type. Could you point us to where you find that information?

    https://www.dummies.com/programming/visual-basic/standard-vba-data-types/ showed that fixed length is a standard VBA Data Types.


    HungChun Yu (MSFT)

    Monday, May 11, 2020 11:04 PM
  • Hi Cezary

    Request send to fix the following typo in [MS-VBAL]

    In section 6.1.2.7.1.5 IsError, Runtime Semantics: ``IsEmpty returns...''. Should be ``IsError returns...''.

    In section 6.1.2.7.1.8 IsNumeric, Runtime Semantics: there is no mentioned of  ``Boolean'' for which the function returns ``true'' as well.

    Thank you for reporting the issues to Microsoft Protocol Open Specifications Support.


    HungChun Yu (MSFT)

    Wednesday, May 13, 2020 5:04 PM
  • Hello,

    FLSes are not BUILTIN-TYPE according to a syntax specification of BUILTIN-TYPE mentioned by Jeff McCashland in a preceding post. Now, there is:

    const-as-clause = "as" BUILTIN-TYPE

    It should be:

    const-as-clause = "as" ( BUILTIN-TYPE / fixed-length-string-spec )

    FLSes are allowed in const definition/declaration.

    -- best regards


    Tuesday, May 26, 2020 10:00 AM
  • Thank you for your question.  An engineer from the protocols team will contact you soon

    Bryan S. Burgin Senior Escalation Engineer Microsoft Protocol Open Specifications Team

    Wednesday, May 27, 2020 9:26 PM
    Moderator
  • Hi Cezary

    I found the following - There are two kinds of strings: variable-length and fixed-length strings.

    https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/string-data-type

    String data type definition

    • A variable-length string can contain up to approximately 2 billion (2^31) characters.
    • A fixed-length string can contain 1 to approximately 64 K (2^16) characters.

    Additional request send to fix following issues with [MS-VBAL] 

    Under 2.1 Data Values and Value Types
          

    String
    (variable length)

    The zero length empty string and all possible character sequences using characters from the implementation dependent character set. There MAY be an implementation defined limit to the length of such sequences but the limit SHOULD be no more than (2<sup style="box-sizing:border-box;font-size:10.5px;">16</sup> – 1) characters.

    Sequences of 16-bit binary encoded Unicode code points.


    String*n
    (fixed-length)

    The length of string is between 1 to 65526
    1 to approximately 64 K (2^16) characters

    Under 2.2 Entities and Declared Types
            String*n, where n is an integer between 1 and 65526



    HungChun Yu (MSFT)

    Thursday, May 28, 2020 9:47 PM
  • I'm sorry, I'm not asking about string types. The point is: grammar rule definitions in [MS-VBAL] are incomplete:

    1. Is

    Const myConst As String * 1 = "12"

    a valid declaration or not? Excel 2007 says ``yes''.

    2. Has abovementioned construct (recognized as a valid one by Excel 2007) a conforming grammar description? No, because a grammar description of ``const-as-clause'' does not allow fixed length strings. That is implied by a fact that a description of ``BUILTIN-TYPE'' (abovementioned by Jeff McCashland) does not allow fixed length strings. So my suggestion is to replace

    const-as-clause = "as" BUILTIN-TYPE

    with
    const-as-clause = "as" ( BUILTIN-TYPE / fixed-length-string-spec )
    -- best regards

    Friday, June 12, 2020 3:51 PM
  • Hi Cezary

    1. Following construct is still valid with Excel 2016, where myConst = "1"

    Const myConst As String * 1 = "12"

    2. It does have to do with string type definition. Fixed-length-string is still considered a string type. Hence it's will be part of of "BULTIN-TYPE", therefor there will be no change to const-as-clause at this time.

    We do plan to expand section 2.1 Data Values and Value Types to include definition of fixed-length-string. Hopefully, this helped answer your question.


    HungChun Yu (MSFT)


    Friday, June 12, 2020 4:41 PM
  • Hello,

    Ad. 2. Expanding a definition of ``BUILTIN-TYPE'' has one danger: ``BUILTIN-TYPE'' is a part of ``type-expression'' which, in turn, is a part of ``function-type'' and ``parameter-type''. However both (``function-type'' nor ``parameter-type'') do not permit FLSes! (Quite justly because FLSes are native VB's constructs, probably coming from early Z80's Basics.) Is not it simpler to go by a ``Variable Type Declarations'' way (5.2.3.1.4):

    as-type = "as" type-spec

    type-spec = fixed-length-string-spec / type-expression

    and to change a definition of ``const-as-clause'' in the same manner, is it?

    -- best regards


    Monday, June 15, 2020 1:17 PM
  • Hi Cezary

    You raised a good point. I will share your concerns with the product group and let you know the outcome. 


    HungChun Yu (MSFT)

    Monday, June 15, 2020 7:07 PM
  • Hi Cezary

    Updated MS-VBAL has been published

    https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/MS-VBAL/d5418146-0bd2-45eb-9c7a-fd9502722c74

    Under 2.1 Data Values and Value Types
          

    String
    (variable length)

    The zero length empty string and all possible character sequences using characters from the implementation dependent character set. There MAY be an implementation defined limit to the length of such sequences but the limit SHOULD be no more than (2<sup style="box-sizing:border-box;font-size:10.5px;">16</sup> – 10) characters.

    Sequences of 16-bit binary encoded Unicode code points.


    String*n
    (fixed-length)

    The length of string is between 1 to 65526
    1 to approximately 65 K (2^16 - 10) characters

    Under 2.2 Entities and Declared Types

            String*n, where n is an integer between 1 and 65526


    In section 6.1.2.7.1.5

    § IsError returns True if the data value of Arg is an Error data value. Otherwise, it returns False



    In section 6.1.2.7.1.8

    § IsNumeric returns True if the value type of the data value of Arg is any of ByteCurrencyDecimalDoubleIntegerLongLongLong, Single or Boolean. Otherwise, it returns False.


    HungChun Yu (MSFT)


    Thursday, August 20, 2020 3:58 PM