* Determining programatically whether the interpreter is Guile or Clisp or Emcs @ 2013-07-29 8:21 白い熊 2013-07-29 8:36 ` Nala Ginrut 2013-07-31 10:24 ` Alexei Matveev 0 siblings, 2 replies; 18+ messages in thread From: 白い熊 @ 2013-07-29 8:21 UTC (permalink / raw) To: guile-user Hello: I'm developping a program which I'd like to be able to use without modification with Guile as the interpreter as well as Emacs lisp and clisp. So far, I was only programming for Emacs/Clisp, for this I used a rather crude check of: (defun kx-emacsp () (not (functionp #'function-lambda-expression))) This was enough, as function-lambda-expression is not defined in elisp. I would like to program for Guile as the lowest denominator. What is the proper check I should define that would tell me whether I'm currently interpreting the code in Guile, or Emacs, or Crisp. Thank you very much for helping me. -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 8:21 Determining programatically whether the interpreter is Guile or Clisp or Emcs 白い熊 @ 2013-07-29 8:36 ` Nala Ginrut 2013-07-29 11:21 ` 白い熊 2013-09-07 9:31 ` Andy Wingo 2013-07-31 10:24 ` Alexei Matveev 1 sibling, 2 replies; 18+ messages in thread From: Nala Ginrut @ 2013-07-29 8:36 UTC (permalink / raw) To: 白い熊; +Cc: guile-user On Mon, 2013-07-29 at 10:21 +0200, 白い熊 wrote: > Hello: > > I'm developping a program which I'd like to be able to use without modification with Guile as the interpreter as well as Emacs lisp and clisp. > Hi! Welcome to Guile! > So far, I was only programming for Emacs/Clisp, for this I used a rather crude check of: > > (defun kx-emacsp () > (not (functionp #'function-lambda-expression))) > > This was enough, as function-lambda-expression is not defined in elisp. > > I would like to program for Guile as the lowest denominator. > > What is the proper check I should define that would tell me whether I'm currently interpreting the code in Guile, or Emacs, or Crisp. > If you just want to check whether a symbol was defined, try: (module-defined? (current-module) 'function-lambda-expression) > Thank you very much for helping me. Regards. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 8:36 ` Nala Ginrut @ 2013-07-29 11:21 ` 白い熊 2013-07-29 11:32 ` Nala Ginrut 2013-07-31 2:27 ` Nala Ginrut 2013-09-07 9:31 ` Andy Wingo 1 sibling, 2 replies; 18+ messages in thread From: 白い熊 @ 2013-07-29 11:21 UTC (permalink / raw) To: guile-user Nala Ginrut <nalaginrut@gmail.com> wrote: >> I would like to program for Guile as the lowest denominator. >> >> What is the proper check I should define that would tell me whether >I'm currently interpreting the code in Guile, or Emacs, or Crisp. >> > >If you just want to check whether a symbol was defined, try: >(module-defined? (current-module) 'function-lambda-expression) Hi: Thanks for the tip. What I'm trying to do: I have a host of kx-... functions which I want to call from any interpreter with the same syntax, i.e. let's say for instance (kx-file-open "funny-file.txt") Now, within the kx-file-open I need to find out whether I'm in guile or clisp or emacs, via a function call, let's say kx-interpreter. This function should return let's say 0 for guile, 1 for clisp and 2 for emacs. Based on this, the file open function will use the appropriate lisp syntax for opening the file. Now I'm wondering what the most effective / fastest way is to find out not whether a symbol is defined, but basically the answer to the self-awareness question: am I in guile, or am I in emacs... -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 11:21 ` 白い熊 @ 2013-07-29 11:32 ` Nala Ginrut 2013-07-29 11:53 ` 白い熊 2013-07-31 2:27 ` Nala Ginrut 1 sibling, 1 reply; 18+ messages in thread From: Nala Ginrut @ 2013-07-29 11:32 UTC (permalink / raw) To: 白い熊; +Cc: Guile User [-- Attachment #1: Type: text/plain, Size: 1433 bytes --] I think the most efficient way is to use 'cpp' of gcc to do the pre-processer, or you have to try eval-when, please read the manual for it. 在 2013-7-29 PM7:23,"白い熊" <guile-user_gnu.org@sumou.com>写道: > Nala Ginrut <nalaginrut@gmail.com> wrote: > > >> I would like to program for Guile as the lowest denominator. > >> > >> What is the proper check I should define that would tell me whether > >I'm currently interpreting the code in Guile, or Emacs, or Crisp. > >> > > > >If you just want to check whether a symbol was defined, try: > >(module-defined? (current-module) 'function-lambda-expression) > > Hi: > > Thanks for the tip. > > What I'm trying to do: I have a host of kx-... functions which I want to > call from any interpreter with the same syntax, i.e. let's say for > instance (kx-file-open "funny-file.txt") > > Now, within the kx-file-open I need to find out whether I'm in guile or > clisp or emacs, via a function call, let's say kx-interpreter. > > This function should return let's say 0 for guile, 1 for clisp and 2 for > emacs. Based on this, the file open function will use the appropriate lisp > syntax for opening the file. > > Now I'm wondering what the most effective / fastest way is to find out not > whether a symbol is defined, but basically the answer to the self-awareness > question: am I in guile, or am I in emacs... > > -- > 白い熊 > > [-- Attachment #2: Type: text/html, Size: 1862 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 11:32 ` Nala Ginrut @ 2013-07-29 11:53 ` 白い熊 0 siblings, 0 replies; 18+ messages in thread From: 白い熊 @ 2013-07-29 11:53 UTC (permalink / raw) To: guile-user Nala Ginrut <nalaginrut@gmail.com> wrote: >I think the most efficient way is to use 'cpp' of gcc to do the >pre-processer, or you have to try eval-when, please read the manual for OK, I did read up on it, but it's not a parent how to go about this interpreter testing. I don't want to get a preprocessor into it, because I want to be able to call the same functions whether I'm in a clisp interpreter, or guile etc. and want to do it it lisp. If it's just figuring out whether I'm in clisp or Emacs, the functionp call is good, as the function I use to test is not defined in Emacs, so I know I'm in lisp. If it's just deciding between guile and Emacs, it's easy too, a simple (version) gives info on the Emacs version or guile. But if call version from clisp it bombs, because there is no such function... But I can't use module-defined? because it's not defined in lisp or elisp. I think I'm missing something very simple... -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 11:21 ` 白い熊 2013-07-29 11:32 ` Nala Ginrut @ 2013-07-31 2:27 ` Nala Ginrut 2013-07-31 4:47 ` 白い熊 1 sibling, 1 reply; 18+ messages in thread From: Nala Ginrut @ 2013-07-31 2:27 UTC (permalink / raw) To: 白い熊; +Cc: guile-user On Mon, 2013-07-29 at 15:21 +0400, 白い熊 wrote: > Nala Ginrut <nalaginrut@gmail.com> wrote: > > >> I would like to program for Guile as the lowest denominator. > >> > >> What is the proper check I should define that would tell me whether > >I'm currently interpreting the code in Guile, or Emacs, or Crisp. > >> > > > >If you just want to check whether a symbol was defined, try: > >(module-defined? (current-module) 'function-lambda-expression) > > Hi: > > Thanks for the tip. > > What I'm trying to do: I have a host of kx-... functions which I want to call from any interpreter with the same syntax, i.e. let's say for instance (kx-file-open "funny-file.txt") > > Now, within the kx-file-open I need to find out whether I'm in guile or clisp or emacs, via a function call, let's say kx-interpreter. > I have no better idea but I think it can be handled by 'catch exception', but I don't think guile/clisp/emacs have same procedure named 'catch' or else. > This function should return let's say 0 for guile, 1 for clisp and 2 for emacs. Based on this, the file open function will use the appropriate lisp syntax for opening the file. > > Now I'm wondering what the most effective / fastest way is to find out not whether a symbol is defined, but basically the answer to the self-awareness question: am I in guile, or am I in emacs... > Here's a dilemma, unless guile/clisp/emacs have the same checker-procedure with same name and definition, you have no promise to check it under different language environment. The best way is prepossess which is portable. Maybe there's better idea I didn't know? Thanks! ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 2:27 ` Nala Ginrut @ 2013-07-31 4:47 ` 白い熊 2013-07-31 5:35 ` Nala Ginrut 2013-07-31 5:35 ` Nala Ginrut 0 siblings, 2 replies; 18+ messages in thread From: 白い熊 @ 2013-07-31 4:47 UTC (permalink / raw) To: guile-user Nala Ginrut <nalaginrut@gmail.com> wrote: >Here's a dilemma, unless guile/clisp/emacs have the same >checker-procedure with same name and definition, you have no promise to >check it under different language environment. The best way is >prepossess which is portable. Yes, I have been thinking very hard about this. The closest I came is apropos. At least (apropos "guile") gives empty feedback in clisp and (apropos "clisp-data") is empty in guile and so on... So I could differentiate based on this. However there's no numeric output so I can't do a cond based on (= ... comparison of output as= is the only equality function the three share so it seems back to square one.... So close.... -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 4:47 ` 白い熊 @ 2013-07-31 5:35 ` Nala Ginrut 2013-07-31 5:35 ` Nala Ginrut 1 sibling, 0 replies; 18+ messages in thread From: Nala Ginrut @ 2013-07-31 5:35 UTC (permalink / raw) To: 白い熊; +Cc: guile-user On Wed, 2013-07-31 at 08:47 +0400, 白い熊 wrote: > Nala Ginrut <nalaginrut@gmail.com> wrote: > >Here's a dilemma, unless guile/clisp/emacs have the same > >checker-procedure with same name and definition, you have no promise to > >check it under different language environment. The best way is > >prepossess which is portable. > Yes, I have been thinking very hard about this. The closest I came is apropos. > > At least (apropos "guile") gives empty feedback in clisp and (apropos "clisp-data") is empty in guile and so on... So I could differentiate based on this. > > However there's no numeric output so I can't do a cond based on (= ... comparison of output as= is the only equality function the three share so it seems back to square one.... So close.... you may try: (with-output-to-string (lambda () (apropos "guile"))) you're so lucky than "with-output-to-string" appears in clisp, but I'm not familiar with elisp ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 4:47 ` 白い熊 2013-07-31 5:35 ` Nala Ginrut @ 2013-07-31 5:35 ` Nala Ginrut 2013-07-31 6:28 ` 白い熊 1 sibling, 1 reply; 18+ messages in thread From: Nala Ginrut @ 2013-07-31 5:35 UTC (permalink / raw) To: 白い熊; +Cc: guile-user On Wed, 2013-07-31 at 08:47 +0400, 白い熊 wrote: > Nala Ginrut <nalaginrut@gmail.com> wrote: > >Here's a dilemma, unless guile/clisp/emacs have the same > >checker-procedure with same name and definition, you have no promise to > >check it under different language environment. The best way is > >prepossess which is portable. > Yes, I have been thinking very hard about this. The closest I came is apropos. > > At least (apropos "guile") gives empty feedback in clisp and (apropos "clisp-data") is empty in guile and so on... So I could differentiate based on this. > > However there's no numeric output so I can't do a cond based on (= ... comparison of output as= is the only equality function the three share so it seems back to square one.... So close.... you may try: (with-output-to-string (lambda () (apropos "guile"))) you're so lucky that "with-output-to-string" appears in clisp, but I'm not familiar with elisp ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 5:35 ` Nala Ginrut @ 2013-07-31 6:28 ` 白い熊 2013-07-31 6:48 ` Nala Ginrut 0 siblings, 1 reply; 18+ messages in thread From: 白い熊 @ 2013-07-31 6:28 UTC (permalink / raw) To: guile-user Nala Ginrut <nalaginrut@gmail.com> wrote: >you may try: >(with-output-to-string (lambda () (apropos "guile"))) >you're so lucky that "with-output-to-string" appears in clisp, but I'm >not familiar with elisp Very close I think, it exists in elisp too, however (with-output-to-string (lambda () (apropos "clisp"))) is true in guile and there is no way to test equality with "" using = So how do I determine the string is empty with lisp equivalent code? Can't use equal? because it doesn't exist in lisp... -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 6:28 ` 白い熊 @ 2013-07-31 6:48 ` Nala Ginrut 0 siblings, 0 replies; 18+ messages in thread From: Nala Ginrut @ 2013-07-31 6:48 UTC (permalink / raw) To: 白い熊; +Cc: guile-user On Wed, 2013-07-31 at 10:28 +0400, 白い熊 wrote: > Nala Ginrut <nalaginrut@gmail.com> wrote: > >you may try: > >(with-output-to-string (lambda () (apropos "guile"))) > >you're so lucky that "with-output-to-string" appears in clisp, but I'm > >not familiar with elisp > > Very close I think, it exists in elisp too, however > (with-output-to-string (lambda () (apropos "clisp"))) > is true in guile and there is no way to test equality with "" using = > > So how do I determine the string is empty with lisp equivalent code? Can't use equal? because it doesn't exist in lisp... Guile has "string=", clisp has it too, I don't familiar with elisp (if you use elisp in Guile, you could call Guile's own procs too) > -- > 白い熊 > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 8:36 ` Nala Ginrut 2013-07-29 11:21 ` 白い熊 @ 2013-09-07 9:31 ` Andy Wingo 1 sibling, 0 replies; 18+ messages in thread From: Andy Wingo @ 2013-09-07 9:31 UTC (permalink / raw) To: Nala Ginrut; +Cc: 白い熊, guile-user On Mon 29 Jul 2013 10:36, Nala Ginrut <nalaginrut@gmail.com> writes: > If you just want to check whether a symbol was defined, try: > (module-defined? (current-module) 'function-lambda-expression) Alternate spelling: (defined? 'foo) Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-29 8:21 Determining programatically whether the interpreter is Guile or Clisp or Emcs 白い熊 2013-07-29 8:36 ` Nala Ginrut @ 2013-07-31 10:24 ` Alexei Matveev 2013-07-31 10:20 ` Ralf Mattes 1 sibling, 1 reply; 18+ messages in thread From: Alexei Matveev @ 2013-07-31 10:24 UTC (permalink / raw) To: 白い熊; +Cc: guile-user [-- Attachment #1: Type: text/plain, Size: 1186 bytes --] On 29 July 2013 10:21, 白い熊 <guile-user_gnu.org@sumou.com> wrote: > Hello: > > I'm developping a program which I'd like to be able to use without > modification with Guile as the interpreter as well as Emacs lisp and clisp. > > Cond-expand macro was supposed to assist "conditional compilation", see an example below. I am not sure if all implementations you are interested in supply it though. Alexei ;;; ;;; Module/package systems differ between implementaitons: ;;; (cond-expand (guile ;; ;; Primary implementation: ;; (define-module (guile scheduling) #:use-module (ice-9 pretty-print) #:use-module (srfi srfi-1) ; list manipulations #:export (qm-mpts->npts)) ;; To get rid of deprecation warning make import of syncase ;; conditional: (cond-expand ((not guile-2) (use-modules (ice-9 syncase))) ; define-syntax (else))) ; else nothing (else ;; ;; MzScheme, aka PLT Scheme, aka Racket (needs cond-expand macro in ;; ~/.mzschmerc): ;; (require (lib "1.ss" "srfi")) (define (1+ x) (+ 1 x)) (define (sorted? lst pred?) #t))) ; FIXME: lies! [-- Attachment #2: Type: text/html, Size: 1647 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 10:24 ` Alexei Matveev @ 2013-07-31 10:20 ` Ralf Mattes 2013-08-01 1:12 ` Nala Ginrut 0 siblings, 1 reply; 18+ messages in thread From: Ralf Mattes @ 2013-07-31 10:20 UTC (permalink / raw) To: Alexei Matveev; +Cc: guile-user Isn't the main problem here that the OP assumes that all three languages have "the same syntax"? This isn't true at all. They share some basic syntax but any "real" CL/Elisp/Scheme code will use more than this basic subset. And even within this limited syntactic subset, while one syntax will work the same syntactic consgruct will have different _semantics_. Cheers, Ralf Mattes ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-07-31 10:20 ` Ralf Mattes @ 2013-08-01 1:12 ` Nala Ginrut 2013-08-01 12:42 ` 白い熊 0 siblings, 1 reply; 18+ messages in thread From: Nala Ginrut @ 2013-08-01 1:12 UTC (permalink / raw) To: Ralf Mattes; +Cc: guile-user, Alexei Matveev On Wed, 2013-07-31 at 12:20 +0200, Ralf Mattes wrote: > Isn't the main problem here that the OP assumes that all three languages > have "the same syntax"? This isn't true at all. They share some basic > syntax but any "real" CL/Elisp/Scheme code will use more than this basic > subset. And even within this limited syntactic subset, while one syntax > will work the same syntactic consgruct will have different _semantics_. > > Cheers, Ralf Mattes > Yes, I'm afraid you're right, so I said pre-process is more portable. Anyway, the project based on such an assumption will be very fragile. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-08-01 1:12 ` Nala Ginrut @ 2013-08-01 12:42 ` 白い熊 2013-08-01 12:45 ` 白い熊 2013-08-12 12:48 ` Thien-Thi Nguyen 0 siblings, 2 replies; 18+ messages in thread From: 白い熊 @ 2013-08-01 12:42 UTC (permalink / raw) To: guile-user On 2013-08-01 05:12, Nala Ginrut wrote: > On Wed, 2013-07-31 at 12:20 +0200, Ralf Mattes wrote: >> Isn't the main problem here that the OP assumes that all three >> languages >> have "the same syntax"? This isn't true at all. They share some basic >> syntax but any "real" CL/Elisp/Scheme code will use more than this >> basic >> subset. And even within this limited syntactic subset, while one >> syntax >> will work the same syntactic consgruct will have different >> _semantics_. > > Yes, I'm afraid you're right, so I said pre-process is more portable. > Anyway, the project based on such an assumption will be very fragile. I disagree. I'm quite aware of the differences and that is exactly the reason, I'm doing this. Do have to say that originally I assumed the syntax between Lisp and Scheme is much closer, that's right. Anyhow, if it's of any interest, what I'm doing is: I'm developing http://kumatux.org/ What's on the web is the old version, I've converted about half the code to Lisp already and have made it fold both ways Lisp and Elisp. What this means is that I can call any function in Emacs or Clisp, and it'll automatically decide what the interpreter is and then modify the execution of the functions and code, so that the syntactic set is respected. I realize now that this is completely not very feasible - to merge it with Scheme, however would like to at least keep playing with this for petty parts of the project. Just like like the idea of having one .lisp file, that can be called without any preprocessing within Emacs, Clisp, or Guile and it'll run. Currently I like playing with Clisp more, what I like about Guile is that it's a new project, so would like to incorporate it into the game a little too. Anyhow, I've been experimenting with the latest recommendation of: (with-output-to-string (lambda... and seems I'm close, however it coughs up errors in Clisp, so still no go. So if anyone would have alternate ideas, I'd be very much obliged. Thanks for helping me. -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-08-01 12:42 ` 白い熊 @ 2013-08-01 12:45 ` 白い熊 2013-08-12 12:48 ` Thien-Thi Nguyen 1 sibling, 0 replies; 18+ messages in thread From: 白い熊 @ 2013-08-01 12:45 UTC (permalink / raw) To: guile-user On 2013-08-01 16:42, 白い熊 wrote: > Clisp, or Guile and it'll run. Currently I like playing with Clisp > more, what I like about Guile is that it's a new project, so would Meant "GNU project", not "new project". :@) -- 白い熊 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs 2013-08-01 12:42 ` 白い熊 2013-08-01 12:45 ` 白い熊 @ 2013-08-12 12:48 ` Thien-Thi Nguyen 1 sibling, 0 replies; 18+ messages in thread From: Thien-Thi Nguyen @ 2013-08-12 12:48 UTC (permalink / raw) To: 白い熊; +Cc: guile-user [-- Attachment #1: Type: text/plain, Size: 842 bytes --] () 白い熊 <guile-user_gnu.org@sumou.com> () Thu, 01 Aug 2013 16:42:31 +0400 So if anyone would have alternate ideas [...] If you are comfortable w/ starting from a Lisp (Emacs or CLISP) base, perhaps you can find fruitful the "recode" facility of CEDET: http://www.emacswiki.org/emacs/SemanticRecoder This addresses the (unavoidable, you will see) translation requirement, not the "distinguishing the fragility of superficial syntax similarity" part (avoidable, but nonetheless fun to experiment with :-D). Anyway, you can see what pains CEDET takes to grow text into a (com)pliant tree. -- Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) => nil [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2013-09-07 9:31 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-29 8:21 Determining programatically whether the interpreter is Guile or Clisp or Emcs 白い熊 2013-07-29 8:36 ` Nala Ginrut 2013-07-29 11:21 ` 白い熊 2013-07-29 11:32 ` Nala Ginrut 2013-07-29 11:53 ` 白い熊 2013-07-31 2:27 ` Nala Ginrut 2013-07-31 4:47 ` 白い熊 2013-07-31 5:35 ` Nala Ginrut 2013-07-31 5:35 ` Nala Ginrut 2013-07-31 6:28 ` 白い熊 2013-07-31 6:48 ` Nala Ginrut 2013-09-07 9:31 ` Andy Wingo 2013-07-31 10:24 ` Alexei Matveev 2013-07-31 10:20 ` Ralf Mattes 2013-08-01 1:12 ` Nala Ginrut 2013-08-01 12:42 ` 白い熊 2013-08-01 12:45 ` 白い熊 2013-08-12 12:48 ` Thien-Thi Nguyen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).