Skip to content

Conversation

@ingydotnet
Copy link
Contributor

@ingydotnet ingydotnet commented Aug 10, 2025

For runtime loading of .glj files.

Note: this PR includes #88 commits so that one should probably be sorted first.
I can adjust this one to any changes you want there.

To avoid adding things that are often lying around...

The .clj and .glj are to ignore top level scripts for testing stuff.

The GNUmakefile and .cache are for alternate Makefile stuff like I do in
glojurelang#75

If that doesn't get merged I can just symlink to it since GNUmakefile
has precedence over Makefile (for GNU make).
Copy link
Contributor

@jfhamlin jfhamlin left a comment

Choose a reason for hiding this comment

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

thanks for adding the GLJPATH support! left a few comments, mainly on command line parsing and the command line interface

Comment on lines 66 to 68
(let [lib1-dir (str (os.Getenv "PWD") "/test_gljpath_priority1")
lib2-dir (str (os.Getenv "PWD") "/test_gljpath_priority2")
lib3-dir (str (os.Getenv "PWD") "/test_gljpath_priority3")
Copy link
Contributor

Choose a reason for hiding this comment

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

love that we're testing the edge case here! re test directory, i think it'd be preferable to use a temp directory rather than the working directory. os.TempDir will return the path to use for temporary files on the current platform

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f4fd0ac

Comment on lines +28 to +29
// parseArgs parses command line arguments and returns an Args struct
func parseArgs(args []string) (*Args, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i should have called this out in the prior command line flag PR, but as this is getting more involved, let's use the standard library's flag parsing: https://pkg.go.dev/flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8a21eeb

Comment on lines 114 to 115
// Process -I include paths last (add to front of load path, highest priority)
// Process in reverse order so first -I on command line gets highest priority
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems duplicative with GLJPATH, and "include" evokes C/C++ — i'm not sure the -I command line flag makes sense for clojure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8a21eeb

Comment on lines 103 to 111
for i := len(paths) - 1; i >= 0; i-- {
path := paths[i]
if path != "" {
// Skip non-existent path directories
if _, err := os.Stat(path); err == nil {
runtime.AddLoadPath(os.DirFS(path), true)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

could we could drop the true second arg and start iterating from index 0 to get the same result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This all makes sense. I'll update in the morning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably want . at the very end of the loadpath (which is what you had).
It seems like there is 1 other entry in the loadpath when we start adding things here, but I was unable to print its value.

The other things need to be added to the front of the loadpath as I'm doing.

I'll refactor to make 2 funcs: AddLoadPath (same as original) and PrependLoadPath.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e5b9a64

@ingydotnet
Copy link
Contributor Author

I added a commit to support a *glojure-load-path* dynamic var.

Seems useful: c3eb307

@ingydotnet ingydotnet requested a review from jfhamlin August 16, 2025 18:26
@ingydotnet
Copy link
Contributor Author

Closing this and revisiting the concept in #123

@ingydotnet ingydotnet closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants