Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Compiling const array literals
Wed, Sep 28 2016 2:27 AMPermanent Link

Michael Dreher

In the help/Introduction/Literals there are two examples of the array value type:

 -  ['This','is','a','string','array','literal']
 - [100,2,45]

So I tried

const
 s1 = ['This','is','a','string','array','literal'];
 s2 = [100,2,45];

and get a compiler error

 -  "[Error]: Duplicate identifier declaration array of ".

Of what? There is a training blank in the error string. Where is my mistake?

Michael Dreher



Attachments: CodeExampleConstArray.zip
Wed, Sep 28 2016 4:01 AMPermanent Link

Matthew Jones

Michael Dreher wrote:

> const

Shouldn't that be var?

--

Matthew Jones
Wed, Sep 28 2016 4:55 AMPermanent Link

Michael Dreher

"Matthew Jones" wrote:

 // > const
 // Shouldn't that be var?

In the library code I've found examples, where array literals are assigned to local vars (WebCore.isDay for example). But then the help defines:

 // <Constant Declaration> =
 //      <Constant Name> = <Expression>
 //
 // The <Expression> element can be any valid expression that does not contain any variable, function,
 // or procedure references. In other words, the expression can only contain other constant references,
 // or literal expressions.

And on a global scope I'd ensure the values are not modified, hence const.
Interesting: s1 and s2 can be compiled without errors, but mutually exclusive and not together.

Michael Dreher
Wed, Sep 28 2016 5:27 AMPermanent Link

Matthew Jones

Michael Dreher wrote:

> Interesting: s1 and s2 can be compiled without errors, but mutually
> exclusive and not together.

In which case, report it to Tim via email with a sample project. Sounds
like a compiler issue.

--

Matthew Jones
Wed, Sep 28 2016 5:44 AMPermanent Link

Michael Dreher

"Matthew Jones" wrote:

 // In which case, report it to Tim via email with a sample project. Sounds
 // like a compiler issue.

That's why I already attached the project code in my first post of this thread Smile

Michael Dreher
Mon, Oct 3 2016 1:05 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< In the help/Introduction/Literals there are two examples of the array value type:

 -  ['This','is','a','string','array','literal']
 - [100,2,45]

So I tried

const
 s1 = ['This','is','a','string','array','literal'];
 s2 = [100,2,45];

and get a compiler error >>

Those are variable examples, and apparently the compiler is having an issue with using them in a const section.  I'll check it out.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 3 2016 1:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

No, it wasn't the const section, it was the way that the compiler was naming array types that are created "on-the-fly" for use in one-offs like consts.

It's now fixed.

Tim Young
Elevate Software
www.elevatesoft.com
Image