1

I'd like to have the starting position of my agents configurable. Within the Chapel code I have

var DOG_STARTING_POSITION: [1..0] int;

Then within the .cfg file I have

DOG_STARTING_POSITION=[25,25]

But this produces the error

error: type mismatch in assignment from string to int(64)
Brian Dolan
  • 3,086
  • 2
  • 24
  • 35
  • 1
    I believe this is a duplicate of https://stackoverflow.com/questions/47712619/is-it-possible-to-declare-an-array-with-config - I saw you opened an issue for it - thanks! – ben-albrecht May 22 '18 at 12:04
  • Possible duplicate of [Is it possible to declare an array with config?](https://stackoverflow.com/questions/47712619/is-it-possible-to-declare-an-array-with-config) – ben-albrecht May 23 '18 at 18:27

1 Answers1

0

Can I use an array as a config const in Chapel ?

No.

This was explained by @bencray already in 2017/12 that

this is not yet supported in Chapel as of Chapel 1.16

In the meantime, a common proxy-solution exists:

One may always arrange inputs to take place from a configuration file ( a common step in a such configurable, pipeline organised computation flows ), given the wish is to read the whole configurable-array content.

If the attempt above was actually a wish to use a form of configurable means of indirect addressing, let's

// DOG_STARTING_POSITION     = [25, 25]
   DOG_STARTING_POSITION_ROW =  25
   DOG_STARTING_POSITION_COL =  25

// and the already compiled code may later freely reference the value by:

   DOG_STARTING_POSITION     = anArrayCONTENT[ DOG_STARTING_POSITION_ROW,
                                               DOG_STARTING_POSITION_COL
                                               ];
/* using the indirect-addressing,
         delivered as
                      config const ( i.e. as trivial int coordinates
                                          from outside
                                          the code-execution context
                                          )
                   as late as
                   at run-time
                   */
user3666197
  • 1
  • 6
  • 50
  • 92