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

Study alternatives to use of auto_index for on-demand compilation #80

Open
andreas-kupries opened this issue Oct 13, 2017 · 2 comments
Open
Assignees
Labels

Comments

@andreas-kupries
Copy link
Owner

andreas-kupries commented Oct 13, 2017

In mode compile&run Critcl currently populates the auto_index array with the declared commands, so that the standard unknown can trigger the compilation on first use.

Proposed alternatives:

  • rkeene : Create Tcl shims which trigger compilation and get replaced with the compilation result.
  • dgp : Hook into namespace unknown.

Study feasibility of either.

For background, there is some intent and pressure on the core to remove auto_index.

A first thing to do would be to isolate the code doing the registration (if it is not already).
Then it can be replaced with alternate implementations.

Thoughts:

  • The idea of shims is likely the most portable not depending on any specific version of the core, and its features. I.e. namespace unknown is a recent feature we would have to check for before using it.
  • The current code is portable across major versions simply because auto_index exists since pretty much the beginning. That breaks should auto_index go away. Plain Tcl procs on the other hand will never go away.
@rkeene
Copy link

rkeene commented Oct 13, 2017

I added the shim proc in tcc4tcl's basic critcl wrapper here: http://chiselapp.com/user/rkeene/repository/tcc4tcl/artifact?ln=68-85&name=f455727caf579fa7

And it seems to work

@andreas-kupries
Copy link
Owner Author

Thank you. Copied into here

    68  proc ::critcl::cproc {command argList resultType body} {
    69  	set handle [::critcl::_allocateHandle]
    71  	set command [::tcc4tcl::lookupNamespace $command]
    73  	$handle cproc $command $argList $resultType $body
    75  	set body {
    76  		set args [uplevel 1 set args]
    78  		::critcl::_go $handle
    81  		tailcall $command {*}$args
    82  	}
    84  	proc $command args [list apply [list {handle command} $body] $handle $command]
    85  }

Regular critcl might be able to work without apply, and tailcall conditionally (8.6+), uplevel otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants