Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refer core namespace to user namespace only when building slow version #351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/environment_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ func NewEnv() *Env {
MakeMeta(nil, "Map of configuration key/value pairs for linter mode", "1.0"))
return res
}

func (env *Env) ReferCoreToUser() {
env.FindNamespace(MakeSymbol("user")).ReferAll(env.CoreNamespace)
}
1 change: 0 additions & 1 deletion core/gen_data/gen_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const hextable = "0123456789abcdef"
func main() {
namespaces := map[string]struct{}{}

GLOBAL_ENV.FindNamespace(MakeSymbol("user")).ReferAll(GLOBAL_ENV.CoreNamespace)
for _, f := range CoreSourceFiles {
GLOBAL_ENV.SetCurrentNamespace(GLOBAL_ENV.CoreNamespace)
content, err := ioutil.ReadFile("data/" + f.Filename)
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ func main() {
RT.GIL.Lock()
ProcessCoreData()

GLOBAL_ENV.FindNamespace(MakeSymbol("user")).ReferAll(GLOBAL_ENV.CoreNamespace)

GLOBAL_ENV.ReferCoreToUser()
Copy link
Owner

Choose a reason for hiding this comment

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

Won't this fail compilation with fast_init tag since ReferCoreToUser is not available with fast_init?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gen_code.go (which generates the fast_init stuff, so that doesn't actually work yet on master anyway) generates an empty ReferCoreToUser implementation into a_code.go. So this does work on the gen-code branch.

That's arguably a bit of a kludge, in that it could go into a proper *.go file compiled only with +build fast_init.

But right now there's not really any such "source" file in the ordinary sense, so I threw it into the generated a_code.go file.

Do you want it somewhere else? E.g. a core/fast_init.go file, with the "slow" version going into core/slow_init.go? They'd start out with just this one receiver in them, but might grow over time to include more stuff that isn't really specific to other existing files.

Or, we could put it in core/environment_fast_init.go and rename core/environment_init.go to core/environment_slow_init.go (and maybe the other core/*_init.go files accordingly, for consistency).

(As an aside, one of the things I absolutely adore about Go is the ability to do such simple renaming without having to edit Makefiles....)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upon further consideration, I find I'm really liking the idea of all *_init.go files being either *_slow_init.go or *_fast_init.go.

I've updated my pending gen-code branch to put the empty implementation of this new receiver into core/environment_fast_init.go.

Then, unless I hear otherwise from you, I'll go forward with a (separate) renaming PR, that also adds the new source file from the gen-code branch.

But this current PR should be fine as-is, in the sense that it won't break anything.

Copy link
Owner

Choose a reason for hiding this comment

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

This makes sense, thanks!

GLOBAL_ENV.SetEnvArgs(remainingArgs)
GLOBAL_ENV.SetClassPath(classPath)

Expand Down