I write these code and compile withnewlisp. I wrote these code:
(defun getdone ()(format t "we have a IDE for cLisp"))
getdone()
and the error message
ERR: invalid function : (defun getdone () (format t "we have a IDE for cLisp"))
====================
I finally realized that it is syntax error because newlisp's grammar is different from clisp's grammar. Now my code is runing well:
(define (getdone) (format "we have a IDE for cLisp"))
(getdone)
I don't know what is the t in format t used for ?
The function call should be
(getdone)
not getdone().
If you're using newLISP, don't use
defun
use
define
to define all your functions.
if you're not using newLISP, your question's tags are wrong.
Related
I am using (string-ith "hello" 3) in Geiser environment within Emacs. It is showing an error
string-ith: undefined;
cannot reference an identifier before its definition
in module: top-level
context...:
eval-one-top
/usr/share/racket/collects/racket/repl.rkt:11:26
I tried the same thing in Dr.Racket IDE. Using the default #lang racket, it is throwing the same error,
> (string-ith "hello" 3)
. . string-ith: undefined;
cannot reference an identifier before its definition
>
but with changing the language to beginning student, it is working properly.
> (string-ith "hello" 3)
"l"
>
I tried with (require racket/string) but of no use.
I am finding it difficult working with racket. Can anyone clarify the reason?
It's simply that the procedure isn't predefined in those languages, as the errors say. It's provided in Beginning Student as a convenience.
If you want it, then use an existing procedure like substring to define it yourself. Or, if you're less motivated, this page suggests a way to import it.
I'm working on a Racket script (on a Linux machine) that requires the math/number-theory library. My entire script at the moment is thus:
#!/usr/bin/racket
(require math/number-theory)
Yes, it's literally just requiring the library.
When I try to run it, I get an error that reads "expected a `module' declaration found: something else".
However, when I actually start up Racket in the terminal like so:
/usr/bin/racket
and enter (require math/number-theory) in the command line, it treats it like it's totally valid.
What's going on here?
Make sure the top of your racket files contains a #lang statement as well.
In other words, you need this at the top of the file:
#!/usr/bin/racket
#lang racket
I am building a program that uses Bing's search API and common lisp with the Drakma library to display some results but for some reason have an error when sending a longer length query It doesn't display any of the results at all. It works for shorter length queries. I am using a temp account for this question. I have the following code.
(defun get-rid-of-spaces (var)
(cl-ppcre:regex-replace-all " " var "%20"))
(defun print-bing (search-term)
(format nil "https://api.datamarket.azure.com/Bing/Search/v1/Web?Query=%27~a%27&Options=%27DisableLocationDetection%27&$format=json&$top=1" (get-rid-of-spaces search-term)))
(defun drakma-bing (search-term)
(drakma:http-request (print-bing search-term)
:basic-authorization
'("bob.hammerston#mailinator.com" "L2gbaj+s1/KW/+ifAa9HrP0C1/kClpF4InH48Lw8UNc")))
(defun convert-to-string (response)
(map 'string #'code-char response))
And then I call this but it only works for short search terms and I can't figure out why. This doesn't work:
(convert-to-string (drakma-bing "what is the largest man in the world"))
But this does
(convert-to-string (drakma-bing "what is"))
Any idea why?
Thanks.
Edit:
I tried encoding the print-bing function by hand instead of using that function with a longer string and it still doesn't work so there must be an error with Drakma. I tried typing the domain into the web browser by hand and it works so that is why I think the error is with Drakma.
You need to use + instead of %20 for spaces.
(defun get-rid-of-spaces (var)
(cl-ppcre:regex-replace-all " " var "+"))
My package, lispy, uses a function from ace-jump-mode.
I'm still thinking if I should use ;; Package-Requires: cookie
or featurep for it, but the main issue is that I want a clean byte-compile
with emacs -q.
I thought that this should eliminate the byte-compilation warning:
(declare-function ace-jump-char-mode "ext:ace-jump-mode")
But it's not the case. Any thoughts on this?
Exactly, the warning is "the following functions are not known to be defined: ace-jump-char-mode, helm".
If that function is likely to be used in most cases where lispy is used, then you shoud just use something like (require 'ext:ace-jump-mode).
I'm working through Land of Lisp, using CLisp, writing the code in Vim with Slimv, then alt-tabbing to another terminal window and loading the file into the REPL with (load 'file.lisp), then running the programs at the REPL.
When I get an error in the REPL, is there any way to ascertain what line in file.lisp the error occurred on? I don't see line numbers mentioned explicitly in the REPL error output, is there any other way?
I found this similar question, but the only answer says to use something other than Clisp like sbcl, allegro, etc.:
How can I improve clisp error messages?
Thanks!
Simple answer: Just compile the code instead of loading it into the REPL: clisp -c file.lisp. Compiler error/warnings show the line numbers. Debug it that way, then load into the REPL. Good enough for now.
If you just want to know what function it occurred in, you can use ":bt" at the REPL prompt when an error happens. It'll print out a GDB-like stacktrace that you can use to figure out which function the error happened at.
The load function in clisp has an :echo option, see the implementation notes. When you use this option your files gets echoed to the output. Hence when an error occurs you can see the corresponding code. For your case the expression would be:
(load 'file.lisp :echo t)
Some extra options may be useful, such as :verbose and :print, in which case the expression would be:
(load 'file.lisp :verbose t :print t :echo t)