-
Notifications
You must be signed in to change notification settings - Fork 17
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
Loading SRFI 169 will automatically turn it on #641
base: master
Are you sure you want to change the base?
Conversation
Currently, ``` stklos> (accept-srfi-169-numbers #f) stklos> 1_2 **** Error: %execute: symbol `1_2' unbound in module `stklos' stklos> (import (srfi 169)) ;; This should turn SRFI 196 on! stklos> 1_2 ;; But it didn't: **** Error: %execute: symbol `1_2' unbound in module `stklos' ``` This adds a line to the SRFI implementation file, that just changes the parameter to #t.
AFAIK it is unconventional for Usually it's done with directives like Gauche supports SRFI 169, but I think the underscore syntax is always on. |
Yes... But it seems to make sense that "if it isn't working and I load the SRFI, it should immediately start working". Anyway, I have no strong preference here. I just realized it could make sense (but then, I'm not really sure it does make sense :) |
It makes more sense from the REPL. But how is a source file like this interpreted: (define-library (srfi 3_4_5)
(import (scheme write) (srfi 1_6_9))
(begin (write 4_5_6))) What about this: (define-library (example)
(import (srfi 169) (srfi 1_2_3))
(import (srfi 2_3_4))
...) |
Hi @lassik . Your second example is interesting. I suppose you're right, and we'd better not letting that happen... |
It's even worse than I considered...
This underscores (no pun intended) that |
On side effects generally:
R7RS section 5.6.1 Library Syntax specifies this. |
Concretely, #!srfi-169
(define-library (lib 2_3_4)
(import (scheme write) (lib 3_4_5))
(begin (write 4_5_6))) Or this: (define-library (lib 234)
#!srfi-169
(import (scheme write) (lib 3_4_5))
(begin (write 4_5_6))) Even this would work: (define-library (lib 234)
(import (scheme write) #!srfi-169 (lib 3_4_5))
(begin (write 4_5_6))) Alll of the above examples work in a consistent way because |
In STklos, that would be implemented by keeping a table of all known The numeric vector SRFIs could be handled using this approach, too. so
|
Actually, that sounds like a very nice idea! And if we can get this to be configurable at runtime (a dynamic table), we could even do things like (define-shebang disable-peephole
(compiler:peephole-optimizer #f))
(define-shebang enable-peephole
(compiler:peephole-optimizer #t)) Then (define (a-function x)
...
...
#!disable-peephole
... ;; this code will not be optimized
...
#!enable-peephole) See, it would not work to change the parameter inside the function, because it won't change the compiler behavior when the function is being compiled. This could perhaps help in debugging and benchmarking. @egallesio what do you think? |
That's a good idea. I recommend Common Lisp's readtables as a model. A readtable is a special type of object that stores settings for the reader. In CL, the special variable
This will not have the intended effect. It's best to have a clean separation between read time (what affects lexical syntax) and expansion/compilation/evaluation time. I recommend this instead: (define (a-function x)
...
...
(with-declare ((optimize (peephole #f)))
... ;; this code will not be optimized
...)) This is patterned after CL's |
The CL standard lets you write things like this:
Compare the result to the non-broken version:
|
Yes, obviously, and I don't know what I was thinking! 😁 You're right! And I like your suggestion! |
Yes, I have programmed in Common Lisp ~20 years ago. It's a really fun language to use! |
Very interesting discussion @lassik: STklos has already two forms (define (a-function x)
...
...
(when-compile (compiler:peephole-optimizer #f))
... ;; this code will not be optimized
...
(when-compile (compiler:peephole-optimizer #t))) @jpellegrini: I have hacked a form similar to your About SRFI-169, the problem is that the default is to accept numbers with underscores, and we need a way to forbid About, changing the syntax when importing a file, we also have this problem, at least, with SRFFI-4 and SRFI-178. However, in these SRFIs, we extend the syntax, we do not modify it (as in SRFI-169 where symbols become numbers). |
Hi @egallesio
A on-liner patch...
Currently,
This adds a line to the SRFI implementation file, that just changes the parameter to #t.