Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - scratchy

#1
Anything else we might add? /
September 03, 2004, 08:17:46 AM
Of course, in an interactive session *LOAD-PATHNAME* is meaningless.
#2
Anything else we might add? /
September 02, 2004, 08:16:53 AM
By the way, clisp has a built-in 'directory-namestring', which is essentially 'dirname', I was asking for in newLISP:



    (defconstant *script-dir* (directory-namestring *LOAD-PATHNAME*))



    (load (concatenate 'string *script-dir* "../lib/common.lsp"))



There you go.
#3
Anything else we might add? /
September 02, 2004, 08:11:03 AM
Quote(load "./lib/common.lsp")  will load from the current directory's lib subdirectory.


Current directory is variable. But the script should be able to figure out where it is located in the filesystem, and without 'dirname', it's impossible to do.


QuoteWhere do you want common.lsp to be?


Anywhere, at a fixed relative path (e.g. "../lib") to a.lsp and b.lsp. Equivalent functionality in sh can be achieved via:



   #!/bin/sh

   source `dirname $0`/../lib/common.sh



The philosophy of sh is to use external programs as much as possible, that is why dirname is not a built-in function in sh.
#4
Anything else we might add? /
August 26, 2004, 07:29:13 AM
Thank you. That brings us back to my point #2 above.
#5
Anything else we might add? /
August 25, 2004, 03:41:24 PM
What's wrong with Lutz advice is that I don't want to write scripts that will work only with my init.lsp.[/quote]
#6
Anything else we might add? /
August 17, 2004, 07:01:43 PM
Quote from: "Lutz"Actually you don't need to use backslash on Win32...

Lutz


??? This information does not help. How about the dirname built-in?
#7
Anything else we might add? /
August 17, 2004, 12:44:30 PM
So it would take something like this:



    (define (dirname path)

        (if (= (& (nth 7 (sys-info)) 0x0F) 6)

            (if (regex "(.*\\).*" path) $1 ".\")

            (if (regex "(.*/).*" path) $1 "./")))



    (define *script-dir* (dirname (nth 1 (main-args))))



in the beginning of each script to be able to include an external script:



    (load (string *script-dir* "../lib/common.lsp"))



I haven't tested this implementation of dirname enough to guarantee that it works everywhere, but having to duplicate the code it is not cool. What else can I do to convince you that dirname should be a built-in?
#8
Anything else we might add? / dirname wanted
August 16, 2004, 06:43:38 AM
Ok, here is a question:



If I am writing several scripts, and I want to put reusable definitions into a separate file, for instance:



  /home/scratchy/bin/a.lsp <-- one script

  /home/scratchy/bin/b.lsp <-- another script

  /home/scratchy/lib/common.lsp <-- reusable stuff



Obviously, in a.lsp and b.lsp I need to locate common.lsp, soft of:



  (load (sting (dirname (nth 1 (main-args))) "../lib/common.lsp"))



[correct me if I'm wrong]. However, I wasn't able to find any built-in "dirname" function. If it's not built-in => I would have to implement it myself => I can't put it into common.lsp because I need it before any file is loaded. Duplicating dirname in the beginning of each script is plain ugly. So is there an elegant solution to this problem?
#9
newLISP in the real world /
August 16, 2004, 06:27:04 AM
Thanks for the replies. Looks like there are at least two ways to do it, which is technically fine.



However the extra syntax on the command-line ([cmd]..[/cmd]) is something that I haven't seen in other shells, and is totally weird. Most shells maintain the same syntax in the script as in interactive session for obvious reasons.



When I fired up newlisp.exe for the first time, and then copied'n'pasted examples from the Web, all I got was a bunch of errors, and that was a big turn off.



I understand that it takes man-power to fix stuff, I'm just pointing out that command-line not working as expected is a rather large drawback as perceived by newbies. And I hope you are not a bunch of stereotypical anti-newbie LISP zealots.



Thanks a lot.
#10
newLISP in the real world /
August 14, 2004, 05:45:19 PM
Looks like you have been pissing in your beer... too :-)
#11
Anything else we might add? /
August 14, 2004, 05:21:52 PM
is that what you do on your period?
#12
Anything else we might add? /
August 14, 2004, 05:18:06 PM
meaning?
#13
Can anyone please explain, why would I use newLISP in my software (no matter how great it is) if I have to ask for a permission (who knows what it implies) to use it? When I don't know where Lutz is and how long he's going to be around? I'd rather use good old /bin/sh + homegrown cruft for my scripting needs, than assume liability. With this, the future of newLISP is close to nil, so enjoy it while it lasts. Thank you.
#14
How come newlisp gives an error when I type or paste a multiline statement into comment prompt? For example:



> (if (env BLAH)



missing parenthesis : "...(if (env BLAH)n"



Of course, the paren is missing, because I haven't finished typing yet!!! The newlisp's IQ must be nil to give such an error, considering that the parser obviously can count the number of opening and closing parens.



And then you claim "You don't study newLISP, you use it" -- In my view newlisp is unusable, and the documentation is not adequate.