From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: Re: Multi-language scripts Date: Sat, 22 Aug 2020 08:22:12 -0700 Message-ID: <170820fc-d7b2-1a2a-93ab-3777eaa5fc74@gmail.com> References: <135D6304-61E4-4826-81BE-4C93257A1F6F@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28613"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Aug 22 17:22:28 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k9VLg-0007Lz-Ep for guile-user@m.gmane-mx.org; Sat, 22 Aug 2020 17:22:28 +0200 Original-Received: from localhost ([::1]:40842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9VLf-0002wL-GN for guile-user@m.gmane-mx.org; Sat, 22 Aug 2020 11:22:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9VLW-0002wD-2d for guile-user@gnu.org; Sat, 22 Aug 2020 11:22:18 -0400 Original-Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:52257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k9VLU-0001d7-AP for guile-user@gnu.org; Sat, 22 Aug 2020 11:22:17 -0400 Original-Received: by mail-pj1-x1032.google.com with SMTP id kr4so2103000pjb.2 for ; Sat, 22 Aug 2020 08:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=8TuhiIikuJv3PtDGbghjtWD8CCyc/V3G1RBgDtAiDLI=; b=GuJLj3Fj9oJ8TzSBBi8kmU6LqIf8rbE6mu/YV+VQfTTP/Z8lcDO9GEFDIe7+A91bAj RJV/tKVYXz5UWO85cm8uozYS5xLfyjJdOCwyIjPjBgZUgSVNhhQKp7iSL/PIpbNefVQV rLWmQiaqGpWWd+lQXAHDx7W/FEH1UxsQjhz19C8rWf5kgVzpzRYFwrq9Bu3t617G+Ze3 yfeJSFAFKqdltKLpg1iPDgMKFiZRsPV/yC05p4T6NlvjXW0WpFcFCtLIvZem1VUbSXpJ Zgr2MYuBOu9DHajl8owtEgSSQA3ShiR0o3bszxklPpSzBUdqx/C1bhN+ba8dNzRQzFVU wEmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=8TuhiIikuJv3PtDGbghjtWD8CCyc/V3G1RBgDtAiDLI=; b=SPChbDIAcNIca5pbEGqioeuxmcyvXfwIQKlyX3wxBS0HhOy8Je3lTdqRKk/5uOwTMb 6dIVEAnCyxTPxaLUiQZD2iygHr4XKlbmp30RCdPn/tO5WOhmogH1kW5KEF90kcbbQSm+ r1LKzWVANcHlaqWrrTS3GqaudH5dHdV0IneUqSCayxlcqjvdME3JHaEXcn5HQRKO6AHQ E8yEXz+T+/jEl70Er9eFmaJw54rB78NlZzJt6yiIsF0BZXhaXfLD8pszfynlGCAgIOwU yCxc8Azy5D1CqoGY8yHU2AGxA5Kd4CV3lQLw+Ws5Yoc7P/QoYN1yJR8dYj/XrXMAFO0t 3BUA== X-Gm-Message-State: AOAM5313o4bAi+Dq//71bUBC6Of63JGXvQT1R5QfDkqsprYUAr11D04/ T1dyRj5Nq0QA+2CWnRnh0SX9RElFbFa8vg== X-Google-Smtp-Source: ABdhPJxSP/8DK+1v2eO/HgFp6YB+s0HcPKFr5UpJQ8+cImoe/z5UgH0S/MtffodxGBAa8O7EmEUrCg== X-Received: by 2002:a17:90a:df11:: with SMTP id gp17mr6602640pjb.140.1598109734427; Sat, 22 Aug 2020 08:22:14 -0700 (PDT) Original-Received: from [192.168.2.183] (64-52-176-132.championbroadband.com. [64.52.176.132]) by smtp.gmail.com with ESMTPSA id n22sm4613330pjq.25.2020.08.22.08.22.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 22 Aug 2020 08:22:13 -0700 (PDT) In-Reply-To: <135D6304-61E4-4826-81BE-4C93257A1F6F@gmail.com> Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=matt.wette@gmail.com; helo=mail-pj1-x1032.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16825 Archived-At: On 8/22/20 7:53 AM, Stephen Scheck wrote: > 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 = #< name: ecmascript title: ECMAScript reader: # printer: # parser: #f compilers: ((tree-il . #)) decompilers: () evaluator: #f joiner: #f for-humans?: #t make-default-environment: #> > scheme@(guile-user)> (current-language $1) > $2 = scheme > scheme@(guile-user)> display("We should be in JavaScript now, but we aren’t!\n”); > $3 = # > 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. > > I think the issue is that while the repl processes one input (line) at a time guile handles files by compiling a file at a time.  I think you'd have to write code to process files an input (line) at a time.  Maybe this could be a procedure that takes the name of the file, generates a repl and feeds the repl from the file one line at a time. (I have played with the compiler code a bit in writing guile-hosted parser/interpreters for javascript, matlab, tcl and others.   Try web search for guile nyacc.) Matt