Shorthand syntax for a slice, map, string literals allocated with the temp allocator (or main allocator) #3761
Beefster09
started this conversation in
Ideas/Requests
Replies: 1 comment
-
my_map: map[string]i8
{
context.allocator = context.temp_allocator
my_map = {"hellope" = 3}
}This is fine if you need to do it once. If you don't need the primary allocator past a certain point, you can assign it to the temporary one from then on. context.allocator = context.temp_allocator
my_map := map[string]i8 {"hellope" = 3}
my_other_map := map[string]i8 {"hellope" = 3} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently you can sidestep this with
slice.clone,strings.clone, and???.clonearound a stack-allocated literal (which allows the value to be returned), but this is long, awkward, and verbose. Would be nice to have something like this:and perhaps there could also be a shorthand for
context.temp_allocatorandcontext.allocator, perhaps#tand#a? Maybe only for this context?Beta Was this translation helpful? Give feedback.
All reactions