Tcl Source Code

View Ticket
Login
Ticket UUID: 2116892
Title: Make SafeBase an actual package
Type: RFE Created on: 2008-09-17 21:57:55
Submitter: dgp Assigned to: aku
Subsystem: 33. Safe Base Severity: Minor
Priority: 5 Medium Last modified: 2020-07-27 14:32:10
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: None
Description:
The set of ::safe::* commands gets
auto-loaded on first use.  I suppose
they're part of the built-in Tcl command
set.


But they're partitioned over in their
own nice namespace, as if they were a
package.  Why not turn them into one?
Call it "safe" so the package name matches
the namespace name.
User Comments:
kjnash (claiming to be [email protected]) added on 2020-07-20 23:22:57:
Good idea.  I hope it can be done at the earliest possible release, subject to rules on breaking compatibility with existing code.  I suppose this will mean Tcl 9.0.

dgp added on 2020-07-23 19:16:40:
Make this one of those "conversation with past self" videos.

I suspect the trouble is the chicken & egg problem.

A safe interpreter, whether created by a Tcl_MakeSafe() call,
or by [interp crate -safe], does not have any exposed commands
that can interact with the file system.  In particular a safe
interp cannot [source] or [load] into place any components that
could make up a "safe" package until the functions of the "safe"
package are already in place to enable safe access to the filesystem.

We would have a circular dependency if we needed to [package require safe]
before we had the capacities in place that would allow us 
to [package require safe].

If there's an escape from this dilemma other than the one we have
(it's in the built-in language command set), let me know.

kjnash added on 2020-07-25 14:01:54:
I agree with your past self!  I think it's about how the file lib/tcl8.6/safe.tcl is loaded in the master - no action is needed in the slave because the master adds the necessary aliases there.  Currently the ::safe::* commands are listed in lib/tcl8.6/tclIndex or equivalent.  The file lib/tcl8.6/safe.tcl could equally well be listed in a pkgIndex.tcl file (or converted to a module), which would need the master interpreter to evaluate "package require safe" before using any ::safe::* commands.

The Safe Base commands are a natural package because they are self-contained in the ::safe namespace.

dgp added on 2020-07-27 14:32:10:
You should know better than me honestly. I never use the facility.