-
Notifications
You must be signed in to change notification settings - Fork 30
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
rename sta::source to sta::include to allow use of tcl source #205
Conversation
sorry - found another issue with package require EDIT: So this is annoying but early returns from a sourced file also have to be emulated for tcllib to work. I'll see what can be done about that. |
Hi Akash- will try, pun not intended, but I really doubt I can because this whole thing is already enough of a Tcl scoping nightmare. I can't just include the forward-compat code either as it has no license. |
If you can use |
- add new global variable, ::sta_scoped_source that if set to 1, causes all sourced files to be evaluated at the scope of the calling function instead of the top level (default 0). read_sdc will always be evaluated at the top-level, however. - ignore early returns when sourcing files - tcl return is supposed to work when sourcing files. see https://www.tcl-lang.org/man/tcl8.6/TclCmd/return.htm for more info Signed-off-by: Mohamed Gaber <donn@efabless.com>
@jjcherry56 Should be ready now. |
I am not a fan of this approach. |
That... would be my preferred approach too. I just assumed you wouldn't want to break existing code. |
- rename sta::source to sta::read_cmds, allowing the original tcl source (which behaves differently, including inheriting the caller's scope) to be used - reverts `69bcdbf507e6e3d45ba471d73d7ae45865ec729c`. Signed-off-by: Mohamed Gaber <donn@efabless.com>
@jjcherry56 Done. |
I tried this myself a few days ago. I decided "include" makes more sense than "read_cmds". |
…atible - sta_warn, sta_error now work with tcl source using a very thin wrapper and a source/include file stack Signed-off-by: Mohamed Gaber <donn@efabless.com>
@jjcherry56 So I implemented a solution to this that works as follows: There's now an
Both
If it's a |
what I had in mind was NOT redefining source and making include set the info file/line properties like source does so it has the same behavior and modifying sta_error/warn to use the info file/line instead of variables or stack |
That'd require include to be partially implemented in C so it can create a new stack frame (I'm unaware of a way to do that in Tcl) -- sadly though, I'd have to tackle that another time as that is far more involved. |
Original PR body follows:
I have chosen to make it opt-in behavior out of an excess of caution. The
~/.sta
issue could technically be resolved by uplevelingsourceTclFile
, but that may have unforeseen consequences. Fortunately, it's not a huge ask to ask users to set ::sta_scoped_source to 1 before package require statements.Resolves #202