Closures, Higher-Order Functions, and Everything in Between #44

Merged
kayomn merged 4 commits from kym-captures into main 2023-11-05 16:52:52 +01:00
Owner

Implements closures into Kym's Chunk-based execution model.

Implements closures into Kym's Chunk-based execution model.
kayomn added this to the (deleted) milestone 2023-11-04 14:43:19 +01:00
kayomn added the
bug
label 2023-11-04 14:43:19 +01:00
kayomn self-assigned this 2023-11-04 14:43:19 +01:00
kayomn added 2 commits 2023-11-04 14:43:20 +01:00
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
88ff2a64b6
Make arguments read-only
kayomn added 1 commit 2023-11-05 13:25:21 +01:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
c86173d759
Fix bugs with n+1-nested closures
kayomn changed title from WIP: Closures, Higher-Order Functions, and Everything in Between to Closures, Higher-Order Functions, and Everything in Between 2023-11-05 13:30:36 +01:00
kayomn reviewed 2023-11-05 15:51:51 +01:00
@ -197,2 +197,4 @@
_ = writer;
_ = value;
return null;
Author
Owner

TODO functions should be unreachable and have a comment.

TODO functions should be unreachable and have a comment.
kayomn marked this conversation as resolved
@ -573,6 +650,7 @@ pub const RuntimeEnv = struct {
break: convert self.new_string(string[0 .. length.?]);
},
.boxed => unreachable,
Author
Owner

Why unreachable?

Why unreachable?
kayomn marked this conversation as resolved
@ -757,6 +861,8 @@ pub const RuntimeRef = opaque {
else => false,
},
.boxed => unreachable,
Author
Owner

Why unreachable?

Why unreachable?
kayomn marked this conversation as resolved
@ -12,6 +16,11 @@ name: *kym.RuntimeRef,
arity: u8,
opcodes: OpcodeList,
constants: ConstList,
bindings: []?*kym.RuntimeRef,
Author
Owner

May be worth replacing with VM managed Buffer object rather than raw Zig array.

May be worth replacing with VM managed Buffer object rather than raw Zig array.
Author
Owner

Actually this is out of scope and really a non-issue right now.

Actually this is out of scope and really a non-issue right now.
kayomn marked this conversation as resolved
@ -14,1 +18,4 @@
constants: ConstList,
bindings: []?*kym.RuntimeRef,
const Box = struct {
Author
Owner

What is this for?

What is this for?
kayomn marked this conversation as resolved
@ -150,3 +170,2 @@
while (opcode_cursor < chunk.opcodes.values.len) : (opcode_cursor += 1) {
switch (chunk.opcodes.values[opcode_cursor]) {
while (opcode_cursor < self.opcodes.values.len) : (opcode_cursor += 1) {
Author
Owner

All these raw illegal state calls may be better as a VM-managed assert function.

All these raw illegal state calls may be better as a VM-managed assert function.
kayomn marked this conversation as resolved
@ -514,0 +635,4 @@
coral.debug.assert(string != null);
app.log_info(string.?);
}
Author
Owner

Debugging code wants removing or moving somewhere else that is easier to switch on or off.

Debugging code wants removing or moving somewhere else that is easier to switch on or off.
kayomn marked this conversation as resolved
@ -551,3 +677,3 @@
pub const typeinfo = &kym.Typeinfo{
.size = @sizeOf(Self),
.name = "lambda",
.name = "func",
Author
Owner

Why rename?

Why rename?
kayomn marked this conversation as resolved
@ -352,0 +390,4 @@
coral.debug.assert(capture.* == .declaration_index);
if (&target_environment.declarations[capture.declaration_index] == declaration) {
Author
Owner

This shouldn't be capable of crashing the process - needs better handling.

This shouldn't be capable of crashing the process - needs better handling.
kayomn marked this conversation as resolved
@ -129,0 +120,4 @@
.declaration = declare: {
if (is_constant) {
break: declare environment.declare_constant(identifier) catch |declaration_error| {
return switch (declaration_error) {
Author
Owner

Shorten to use root.report_declare_error.

Shorten to use `root.report_declare_error`.
kayomn marked this conversation as resolved
@ -129,0 +132,4 @@
}
break: declare environment.declare_variable(identifier) catch |declaration_error| {
return switch (declaration_error) {
Author
Owner

Shorten to use root.report_declare_error.

Shorten to use `root.report_declare_error`.
kayomn marked this conversation as resolved
@ -24,0 +29,4 @@
capture_index: u8,
};
const DeclareError = coral.io.AllocationError || error {
Author
Owner

Should ideally be marked pub as is used on public interface for struct.

Should ideally be marked pub as is used on public interface for struct.
kayomn marked this conversation as resolved
kayomn added 1 commit 2023-11-05 16:51:34 +01:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
816051f066
Amend code review
kayomn merged commit 03a8abc5dd into main 2023-11-05 16:52:52 +01:00
kayomn deleted branch kym-captures 2023-11-05 16:52:52 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kayomn/ona#44
No description provided.