Skip to content

Commit

Permalink
Remove superfluous comment, fix redef-multi*
Browse files Browse the repository at this point in the history
Needlessly created table clones, probably can be improved further however. The
main improvement is, only clone the metadata once, then just create bindings
that share the same metadata.

FossilOrigin-Name: c0755e8963081667646c71e8f03e249af5d3570522bea0e0cab45a797406badb
  • Loading branch information
llmII committed Sep 15, 2021
1 parent 99c8dda commit 43729d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/csys.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ JANET_CFUN(cfun_getpwnam);
JANET_CFUN(cfun_getgrnam);

/* *nix: stdio.h */
JANET_CFUN(cfun_file_handle); /* See later TODO */
JANET_CFUN(cfun_file_handle);
int file_to_fd(Janet *, int);

/*============================================================================
Expand Down
13 changes: 5 additions & 8 deletions sys.janet
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
(import csys :as sys)

# TODO: re-export os/cwd os/cd as sys/current-working-directory and
# sys/change-directory?

# helpers ********************************************************************
# Definition from:
# https://github.com/janet-lang/spork/blob/master/spork/path.janet
Expand Down Expand Up @@ -36,17 +33,17 @@
[from to]
~(redef+ ,(string from) ',to))

# TODO: redef+ on first, redef on rest - don't clone so many tables!
(defn- redef-multi*
``
Helper for redef-multi, does redefs over an indexed collection. Makes each
new symbol exported.
``
[from to]
# TODO strip the match, it's not needed
(match (length to)
0 (redef+ from to)
_ (each n to (redef+ (string from) n))))
(redef+ from (get to 0))
(var idx (- (length to) 1))
(while (> idx 0)
(redef+ (string (get to 0)) (get to idx))
(-- idx)))

(defmacro- redef-multi
"Redef each symbol after the first as the first."
Expand Down

0 comments on commit 43729d5

Please sign in to comment.