Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time.
Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
June 05, 2023 Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
June 06, 2023 Re: Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dany12L | On 6/5/23 11:45 AM, Dany12L wrote: >Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably the reason nobody answered the question yet is that it trivially works if you try it :) Unless you did try it and it didn't work? In that case, post your code, I'm sure we can fix it. -Steve |
June 06, 2023 Re: Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 6 June 2023 at 14:26:01 UTC, Steven Schveighoffer wrote: >On 6/5/23 11:45 AM, Dany12L wrote: >Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably the reason nobody answered the question yet is that it trivially works if you try it :) Unless you did try it and it didn't work? In that case, post your code, I'm sure we can fix it. -Steve My concern would be to create an immutable array (or other "equivalent") of strings by adding elements to the array at compile time from different modules. I would like to know if it is possible to do something similar |
June 06, 2023 Re: Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dany12L | On 6/6/23 4:38 PM, Dany12L wrote: >On Tuesday, 6 June 2023 at 14:26:01 UTC, Steven Schveighoffer wrote: >On 6/5/23 11:45 AM, Dany12L wrote: >Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably the reason nobody answered the question yet is that it trivially works if you try it :) Unless you did try it and it didn't work? In that case, post your code, I'm sure we can fix it. My concern would be to create an immutable array (or other "equivalent") of strings by adding elements to the array at compile time from different modules. OK, so you want to affect the same static variable from multiple places? No, that can't happen that way. You can do it in a functional programming fashion, but there can only be one initialization, you can't edit the thing afterwards. So for instance, you can do:
In a centralized place. -Steve |
June 16, 2023 Re: Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Wednesday, 7 June 2023 at 00:18:54 UTC, Steven Schveighoffer wrote: >So for instance, you can do:
In a centralized place. -Steve Hi, |
June 15, 2023 Re: Dynamic length string array at compile time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mark Fisher | On 6/15/23 9:59 PM, Mark Fisher wrote: >Hi, Well, as long as it's not compile time, but runtime, you can definitely do it. Just use shared static constructors. As far as I know, there's no way to have the compiler build a compile-time list of all compiled modules to be used to build such a thing. You might be able to do it as a pre-build step. One thing you could do is have a convention where some "master" module that knows all of the important modules to includes passes it to some mixin to instantiate. -Steve |