Category talk:Go: Difference between revisions

Content added Content deleted
(various updates)
(Arena storage pool done.)
Line 27: Line 27:
===Add a variable to a class instance at runtime===
===Add a variable to a class instance at runtime===
Go has no dynamic type defintion. All data types are determined and fixed at compile time.
Go has no dynamic type defintion. All data types are determined and fixed at compile time.

===Arena storage pool===
Go uses a single arena, created at program load and managed by the Go runtime. Mmap is available as a syscall, but Go offers no support for initializing a raw block of memory like this as a usable heap and no support for working with multiple managed heaps. Its multiple stacks, I believe, are created within this one arena.


===Calendar - for "real" programmers===
===Calendar - for "real" programmers===
Line 77: Line 74:


==Once omitted, now solved!==
==Once omitted, now solved!==
===Arena storage pool===
Go uses a single arena, created at program load and managed by the Go runtime. Mmap is available as a syscall, but Go offers no support for initializing a raw block of memory like this as a usable heap and no support for working with multiple managed heaps. Its multiple stacks, I believe, are created within this one arena.

Update: Solution posted using sync.Pool. It's no mmap solution, but I think it satisfies the general wording of the task. An mmap solution, probably with cgo, might still be interesting some day.

===Exceptions/Catch an exception thrown in a nested call===
===Exceptions/Catch an exception thrown in a nested call===
The specific wording of the task description excludes Go. It specifies that foo call bar, bar call baz, and foo catch U0. The only execption-like mechanism we have is panic/recover. If foo defers a function that uses recover, it can catch a panic, but it ''cannot continue executing.'' Deferred means deferred to the end and foo is ending one way or another the first time a panic gets to it.
The specific wording of the task description excludes Go. It specifies that foo call bar, bar call baz, and foo catch U0. The only execption-like mechanism we have is panic/recover. If foo defers a function that uses recover, it can catch a panic, but it ''cannot continue executing.'' Deferred means deferred to the end and foo is ending one way or another the first time a panic gets to it.