my_basic icon indicating copy to clipboard operation
my_basic copied to clipboard

Is there a way to have nested dictionaries?

Open angros47 opened this issue 4 years ago • 4 comments

Something like:

a=dict() a(1)=dict()

a(1)(1)="test"

In Lua or Python it is possible. Is it possible in my_basic? The above syntax doesn't work (I know it can be done with GET and SET, but I wondered if there was a more readable way to do it)

I really like this project, for its extreme compactness, and for how much it can achieve with such a small size

angros47 avatar Apr 12 '21 16:04 angros47

Use this:

a = dict
(
  1,
  dict
  (
    1, "test"
  )
)

But the only way to retrieve nested is get(get(a, 1), 1).

paladin-t avatar Apr 13 '21 02:04 paladin-t

Thank you for the quick answer. That's a shame, is there any plan to change that behavior in the future? I think it would increase the potential of the language a lot. Also, how does my_basic perform compared to lua? The ability to use real arrays should make it faster, but lua on the other end claims to have some optimizations.

At the moment I am trying to integrate it with my 3d library OpenB3D, since it seems a promising language.

angros47 avatar Apr 13 '21 08:04 angros47

I forgot to say: I have also ported the header to FreeBasic, to be able to use my_basic from a FB source:

https://www.freebasic.net/forum/viewtopic.php?f=17&t=29109

Feel free to tell me if I made any mistake

angros47 avatar Apr 13 '21 17:04 angros47

For the moment I'm working on other projects, lacking in time to make that change.

I haven't compared array specifically, but Lua is overall faster than MY-BASIC. For my experience the performance of MY-BASIC is already significant to support a variant range of applications.

It's interesting to see MY-BASIC running in another BASIC :D

paladin-t avatar Apr 14 '21 03:04 paladin-t