guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multi-language scripts


From: Stephen Scheck
Subject: Re: Multi-language scripts
Date: Sat, 22 Aug 2020 10:53:50 -0400

Matt Wette wrote:

> maybe this?
>
> (use-modules (system base language))
> (current-language (lookup-language 'ecmascript))

It doesn’t work:

    scheme@(guile-user)> (use-modules (system base language))
    scheme@(guile-user)> (lookup-language ‘ecmascript)
    $1 = #<<language> name: ecmascript title: ECMAScript reader: #<procedure 
7f939b1bb558 at language/ecmascript/spec.scm:33:16 (port env)> printer: 
#<procedure write (_ #:optional _)> parser: #f compilers: ((tree-il . 
#<procedure compile-tree-il (exp env opts)>)) decompilers: () evaluator: #f 
joiner: #f for-humans?: #t make-default-environment: #<procedure 
make-fresh-user-module ()>>
    scheme@(guile-user)> (current-language $1)
    $2 = scheme
    scheme@(guile-user)> display("We should be in JavaScript now, but we 
aren’t!\n”);
    $3 = #<procedure display (_ #:optional _)>
    ERROR: Wrong type to apply: "We should be in JavaScript now, but we 
aren’t!\n”
    
    Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.


Also, even if it did, it would be problematic switching back - you’d need to do 
something along these lines in Scheme first:

(define (string_to_symbol sym) (string->symbol sym))
(define (lookup_language lang) (lookup-language lang))
(define (set_current_language lang) (set-current-language! lang)) ;; assuming 
set-current-language! actually existed…

This wouldn’t work, obviously, in the general case for other languages. I don’t 
really want to use JavaScript, I was just using it as an example.

I really just want some way to enable the REPL reader when you pass a script to 
Guile with the -s switch from the command line so you can embed `,language` 
meta-commands in the script file.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]