Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

fixup: CLI arguments for C, CPP, Go, Ruby #25

Merged
merged 5 commits into from
Aug 2, 2022

Conversation

rjzak
Copy link
Member

@rjzak rjzak commented Jul 28, 2022

C, C++, Go, Ruby receive command line input instead of stdin.

Refs #23

Go has a go.mod to allow it to be built easily with regular Go.

Overall cleanup for consistency.

Copy link
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, let's make sure all of these are consistent

C++/fibonacci/fibonacci.cpp Outdated Show resolved Hide resolved
C++/fibonacci/fibonacci.cpp Outdated Show resolved Hide resolved
Go/fibonacci/go.mod Outdated Show resolved Hide resolved
Go/fibonacci/main.go Outdated Show resolved Hide resolved
@rjzak rjzak force-pushed the fix_c_cpp_go_ruby branch 4 times, most recently from a2c740d to c4a55d5 Compare July 28, 2022 19:00
C++/fibonacci/fibonacci.cpp Outdated Show resolved Hide resolved
C/fibonacci/fibonacci.c Outdated Show resolved Hide resolved
Go/fibonacci/main.go Outdated Show resolved Hide resolved
@rjzak rjzak force-pushed the fix_c_cpp_go_ruby branch 3 times, most recently from 1eb81f2 to 82d3b4c Compare July 28, 2022 21:28
Copy link
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C, C++ and Go examples still incorrectly handle negative numbers:

$ nix build github:rjzak/codex/fix_c_cpp_go_ruby#fibonacci-cpp
$ echo -1 | enarx run ./result/main.wasm                      
Which Fibonacci index to find? Fibonacci sequence number at index -1 is -1
$ nix build github:rjzak/codex/fix_c_cpp_go_ruby#fibonacci-c  
$ echo -1 | enarx run ./result/main.wasm                    
Which Fibonacci index to find? Fibonacci sequence number at index -1 is -1
$ nix build github:rjzak/codex/fix_c_cpp_go_ruby#fibonacci-go
$ echo -1 | enarx run ./result/main.wasm                     
Which Fibonacci index to find? Fibonacci sequence number at index -1 is -1

Meanwhile, Rust and Zig:

$ nix build github:rjzak/codex/fix_c_cpp_go_ruby#fibonacci-rust    
$ echo -1 | enarx run ./result/main.wasm
Enter a non-negative number:
thread 'main' panicked at 'Failed to parse number: ParseIntError { kind: InvalidDigit }', src/main.rs:23:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: KVM error: Shutdown
$ nix build github:rjzak/codex/fix_c_cpp_go_ruby#fibonacci-zig 
$ echo -1 | enarx run ./result/main.wasm                     
No arguments specified, please specify Fibonacci sequence index: 
error: InvalidCharacter
Error: failed to execute default function

Caused by:
    Exited with i32 exit status 1
    wasm backtrace:
        0: 0x35ae - <unknown>!<wasm function 17>

C/fibonacci/fibonacci.c Outdated Show resolved Hide resolved
C/fibonacci/fibonacci.c Outdated Show resolved Hide resolved
Go/fibonacci/main.go Outdated Show resolved Hide resolved
Go/fibonacci/main.go Outdated Show resolved Hide resolved
Go/fibonacci/main.go Outdated Show resolved Hide resolved
@rjzak rjzak force-pushed the fix_c_cpp_go_ruby branch from a61b897 to f685d54 Compare August 1, 2022 22:21
@rjzak rjzak requested a review from rvolosatovs August 1, 2022 22:30
Copy link
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, approving to unblock this and the rest will be fixed in a follow-up!

@rvolosatovs rvolosatovs assigned rvolosatovs and unassigned haraldh Aug 2, 2022
@rvolosatovs rvolosatovs merged commit 390c4ca into enarx:main Aug 2, 2022
@rjzak rjzak deleted the fix_c_cpp_go_ruby branch August 2, 2022 14:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants