SamiKalliomaki / eppabasic

A new web based basic language inspired by CoolBasic.
Other
11 stars 3 forks source link

hashmaps #20

Open fergusq opened 9 years ago

fergusq commented 9 years ago

Tables with string keys

henkkuli commented 9 years ago

What kind of syntax should they use? Probably for accessing data []-syyntax would be appropriate. But how about for the type? What hash function to use? A perfect hash based on trie or some other hash?

fergusq commented 9 years ago

Maybe

Dim map as Integer[String] is a hashmap vs. Dim array as Integer[Integer] = x which would be a variable length array (cannot be initiated, but assigned)

Integer[] would be an alias to Integer[Integer]

henkkuli commented 9 years ago

I think Dim map As Integer[String] should be just intepreted as an Integer array with the size of the value referenced by String. How about using {} for hash maps?

fergusq commented 9 years ago

Do you mean Dim map as Integer{}? That is not logical, as then we should use map{key} as the accessing syntax.

I can't figure out a situation where I needed to create an array which has the size of the string type.

What about syntaxes {String=>Integer}, array [Integer].

fergusq commented 9 years ago

Pascal-like syntaxes Dim map as Map[] of Integer and Dim array as Array[] of Integer could work

They could also support multiple keys, like Dim map as Map[,,] of Integer and Dim array as Array[12, 10] of Integer.

SamiKalliomaki commented 9 years ago

I would prefer the Integer[String] syntax. Note that user should be able to mix hashmaps and regular arrays. Eg. Dim foo As Integer[String][10][10]