dictu-lang / Dictu

Dictu is a high-level dynamically typed, multi-paradigm, interpreted programming language.
https://dictu-lang.com
MIT License
267 stars 53 forks source link

[FEATURE] Set (initial) size of list, set, dict #674

Open briandowns opened 1 year ago

briandowns commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem?

It might be helpful to have the ability to specify the initial size of list, set, and dict. A user would set the initial size of the type but wouldn't prevent them from further extension.

Describe the solution you'd like

var dozen = newList(12);
var daysOfTheWeek = newDict(7);

Describe alternatives you've considered

No response

Additional context

No response

Jason2605 commented 1 year ago

Sounds good to me! I wonder if it's worth having a List / Dict namespace then later on we can add other methods that create these from method calls, i.e:

List.new(<number>);
Dict.new(<Number>);

List.fill(...)
Dict.from([["key", "value"], [...]])
briandowns commented 1 year ago

I was thinking of doing that initially but decided to keep it simple at the outset. I'm happy to do whatever you think is best. I have a working implementation but need to find all the memory I'm leaking. 😂

Jason2605 commented 1 year ago

The joys of C right 😂 If it's not too much trouble I think the namespace would be the way to go as it saves us changing it later down the line

briandowns commented 1 year ago

No trouble at all. I completely it'll be best.