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

Topics - Tim Johnson

#41
Howdy Folks.

given the following:

(set 'l '( 1 2 3 4 5 6 7 8))

;; I'd like to process 'l two elements at a time:

;; which is more efficient?

;; 1)
(dolist (x (explode l 2)) (code-here x))

;; 2)
(set 'l1 (explode l 2))
(dolist (x l1) (code-here x)

;; OR is there a more efficient way than using 'explode?

;; Also, any links to similar topics regarding loop

;; optimization would be warmly welcomed

Cheers

Tim
#42
newLISP newS / Pushing a list as multiple elements
December 28, 2007, 06:48:18 PM
consider the following;
> (set 't '(4 5 6))
(4 5 6)
> (set 'test '(1 2 3))
(1 2 3)
> (push t test -1)
> test
(1 2 3 (4 5 6))

;; Is there an existing function implementation that will give me:
(1 2 3 4 5 6)
Yes, flat will give me those result, but I may not want to

'flatten other elements in the target list.

Thanks

Tim
#43
newLISP newS / Evaluating symbols in nested lists
December 23, 2007, 05:13:36 PM
I have the following symbols and values:

> key

"test"

> res

(("test" "one"))

> val

"one"

> newval

"two"

;; And I want to change 'res to (("test" ("one" "two"))

;; but:
(replace-assoc key res '(key (list val newval)))

;; gives me

(key (list val newval))

I understand that the symbols in '(key (list val newval))

aren't being evaluated, but don't

know which function to use to evaluate them.

Thanks

Tim
#44
My very first newLisp code follows.

FYI: I do a lot of web programming. In some cases, I'm writing

for remote servers where I have complete control, including

secure shell and root access. In other cases, I enjoy the cooperation

of a sysadmin who will do anything for me as long as it is safe.

However, there are domain hosters who will not install a lesser-known

binary, such as rebol or newlisp at a system directory, but will allow

an install under a domain path, such as public_html, so I might

have newlisp running at /home/bin and modules at some arbitrary

directory path.

Thus I wanted an interface that was simple and took care of searching

paths in the background.

First code is the startup module itself. Second a simple CGI script

and lastly the output from the script.

I'd welcome comments and caveats that would further enlighten me

on coding techniques.

TIA

tim

;;---------------------------------------------------------------------------------------------

;; initialization code
;; Search in the following order
;; 1)current directory
;; 2)/usr/share/newlisp/modules/
;; 3)Any other hard-coded paths
(setq sys-path '(""
"/usr/share/newlisp/modules"
"/home/http/run/libraries/newlisp"))
;; -------------------------------------------------------------
;; If a 'symbol does not have an extension, add a default ".lsp"
;; -------------------------------------------------------------
(define (lsp-extend symbol)
  (setq fname (string symbol)) ;; just in case a symbol is passed
  (cond
   ((< (length(parse fname ".")) 2) ;; no extension
(append fname ".lsp"))          ;; add default
   (fname)))
;; -------------------------------------------------------------
;; search for file along directories in 'sys-path
;; return full path to file or nil
;; -------------------------------------------------------------
(define (path-found f)
  (setq file (lsp-extend f))  ;; confirm extension
  (dolist
   (path sys-path) ;; search existing paths, same dir first
   (if(= path "")  ;; check wd first
 (setq test (append (real-path) "/" file))
 (setq test (append path "/" file))) ;; full path
   (if (file? test)    ;; we're outta here!
  (throw test))))
;; -------------------------------------------------------------
;; If found, load file, if not throw error
;; -------------------------------------------------------------
(define (load-from-path file)
  (setq res (catch(path-found file)))
  (cond
   (res (load res)) ;; path found
   ((throw-error    ;; abort with error message
(append file " could not be found in 'sys-path"))))
  res)
;; -------------------------------------------------------------
;; @module usr
;; @syntax (modules "module1 module2 module3 ...")
;;  If a file name does not have an extension, .lsp is appended
;; @example (modules "cgi ftp zlib mylib")
;; @return list of loaded files
;; TODO:
;;   add further arguments, thus module names are
;;     'words' in a string => 'modstring
;;   provide code for a symbol list as an alternative to
;;     a string of modules
;; -------------------------------------------------------------
(define (modules modstring)
  (setq loaded '())  ;; list of loaded modules
  (dolist
   (ms (parse modstring))
   (push ;; accumulate list of loaded modules
(load-from-path ms) loaded))
  loaded)

CGI script

#!/usr/bin/newlisp -c
;; http://localhost/cgi-bin/newlisp/testcgi.lsp
(println "Content-type: text/htmln")
(define resources "cgi ftp cgi1")
(define (main)
  (load "usr.lsp")
  (setq loaded(modules resources))
  (println "<br>$HOME: " $HOME)
  (println "<br>Loaded: " loaded)
  (exit))
(catch (main) 'err)
(if err(println "<pre>ERROR: " err))

Output:

$HOME: /home/http/

Loaded: ("/home/http/run/newlisp/cgi1.lsp" "/usr/share/newlisp/modules/ftp.lsp" "/usr/share/newlisp/modules/cgi.lsp")
#45
newLISP newS / Status of Emacs mode for newlisp
November 16, 2007, 05:37:28 PM
It's me ... I wrote the original draft of the

newlisp editing mode for emacs.



It looks like I'm actually going to be writing some

newlisp code, so what I'd like to do, if possible, is to

hear from any of you who might have made changes to

the mode so that those changes could be synchronized.



The copy on my desktop contains changes made by

frontera000. I believe some other changes may have been

made as well.



I'm inclined to drop the usage of the associative (hash) list

for documentation. I've found it difficult to handle

all of the escaping. So maybe 'nl-doc-assoc will go by the

wayside and w3m (emacs html pager mode) could be

utilized.



Anyway, if anyone has any changes to share, let me know.

Thanks

Tim

P.S. newlisp compiled and installed with incident on ubuntu 7.10 32-bit.
#46
I'm a rebol, python, C programmer. And I have a need for speed. :-)

(We do a lot of intensive data importing and reconfiguring)



FYI: I've been looking at lua as a way of using C as a host application

for scripts, and Lua is really designed for that.



The problem I've run into is that although one can easily install lua packages on ubuntu (for instance) thru apt-get or Adept Manager, installing from source (which might be necessary to install one's work on a remote slackware, redhat or fedora server) is tough. The tarballs are not documented with install instructions, some tarballs are missing header files, and I haven't had any luck getting help from the lua ML. Grrr! :-(



So my question is: Can newlisp be embedded in a C/C++ application so

that the product is an executable?

OR

Is that in newlisp's future?

OR

will linking the newlisp interpreter directly to the code via

link.lsp (as an example) give a significant increase in performance?



Thanks

Tim
#47
newLISP newS / Vim and the enable-interpreter feature
October 30, 2006, 05:21:58 PM
I like emacs because it is essentially a operating environment for a

lisp variant - elisp and therefore pretty much infinitely extendable since

elisp is a General Purpose Programming Language.



elisp isn't a lot of fun to code in tho, it's not as modern as newlisp.



Vim has been developed with 'hooks' so that one can embed a number of

interpreters at compile time. This means that when you are running vim,

you can also be running python, perl, ruby, tcl, csope, netbeans etc.



I have no doubt that newlisp could be embedded in the same fashion.

It would then enable the user to extend the Vim system using newlisp code.



I believe it would take some coordination between Lutz and Bram Moolenar, who is the developer of Vim.



It is likely that Lutz would find Bram very approachable.

My .2 cents worth.

tim
#48
Hi:

Lutz and I have been having a conversation of off the forum and we've

decided that it is worth sharing.

FYI: I have written an application in elisp to create a newlisp syntax mode

for emacs. Part of this project was to provide on-demand documentation

from a keyword context in three different forms:

1)Verbose documentation in a popup window.

2)Verbose documentation in a temporary buffer

3)One-liner description of the interface in the echo area.



To do this I had to make some modifications to newlisp_manual.html.

Here is what I wrote to Lutz:

"""

Lutz said:

> Regarding the doc strings: it should not be very difficult to write a script

> for extracting them from newlisp_manual.html, which strictly uses a limited

> HTML subset. You also could just use 'lynx -dump newlisp_manual.html' to

> generate a pure text file, which then is even easier to parse.



I said:

  Actually, I've used that method. But I couldn't really find a

  pattern to use as a delimiter, so I manually inserted some

  markup - specifically a pseudo-tag <break>.



  Do you have any ideas for a search pattern?



  I think that, given some time

  (:-) and guidance),



  I could come up with a method that generated a file that could

  be used as an intermediary for any number of editors. Certainly

  emacs and vim, and for emacs a text file parsed by emacs itself

  would get around some of the problems with escaping.



  Alternatively here's an approach that would use the website and

  the documentation directly:



  Rebol has a feature called load/markup that auto-parses a document or

  a string into an array of alternating tag and string datatypes -  all

  it takes is:



  load/markup http://www.newlisp.org/downloads/newlisp_manual.html">http://www.newlisp.org/downloads/newlisp_manual.html



  from the command line.



  Anything like that in newlisp?



  Maybe you would like to take this discussion to the forum?

  :-) I've got the time.

 " " "

Lutz replied again:

"""

finding some kind of standard way to parse the newlisp_manual.html into

pieces sounds like a wonderful idea. This idea should definitely be brougth

to the discussion group.



Some short newLISP script using regular expressions should do the thing. As

you mentioned, perhaps some addtions/changes to the manual will facilitate

it further.



Mention this idea on the discussion group.There are several people

experimenting with newLISP development environments based on emacs, vi, gtk,

etc. They all could benefit on a method to quickly extract relevant help

from the manual.



"""

I'll add a couple of other thoughts:

1)There is one - situation where keyword documentation is combined and that is for the arithmetic operators.

2)One should be thinking about ways to include documentation for

   user libraries, third-party contributions etc.



I'm sure there's many other ideas.

thanks

tim
#49
Hi:

I wrote the newlisp mode for emacs. I don't visit this forum frequently and was not aware 'til just now that there have been some modifications and some problems. I see that fontera has contributed some code.



Since emacs is an operating environment for a General Purpose lisp Programming Language (elisp, a 'cousin' of newlisp) I'm hoping that the emacs mode can be a community project and that someone who is a newlisp programmer (I'm not at this time) can take over as a Primary Maintainer.



I'd like to make a proposal for a way to constructively make this mode a organically growing system. For the most part, I think this is also relevant for vim and any other development system in the Open Source venue.



1)Let there be a Primary Maintainer - for now it is me, but I would like to see that change. The Primary Maintainer (PM) should be the one responsible for finalizing code changes.



2)Let there be a single location for publicly posted code modules. I recommend that it be http://newlisp.org/code/">http://newlisp.org/code/ or something like that...



3)If one has code changes to submit, post those changes to the forum, but take care to annotate the code changes so that the PM can easly identify the changes and document them. The contributor should let the PM know also whether he/she wants their email address posted, obfuscated or left out entirely. The PM should receive an email on this subject, a link to the topic in the forum would be sufficient.



4)The PM would then integrate the new code into the existing codebase and then submit it to Lutz for public posting.



5)If there are errors, the PM should be notified similarly as above.



------------------------------------------------------------------------------

Of a practical nature, submiting code changes or additions to the original

author or the current maintainer for implementation creates a single 'code

repository' that allows changes to proceed from one point and would be a more

appealing alternative to numerous "code forks" IMHO.

-------------------------------------------------------------------------------



The following may be more pertinent to GNU emacs and XEmacs than to vim, but bears stating:

----------------------------------------------------------------------------------

Emacs is a very large, system. It is essentially an operating environment for a

General Purpose Programming Language (GPL) called elisp. Elisp modules that are

part of the system and included as part of the standard distribution have to

meet some exacting standards. Regardless of whether someone reading this is an

emacs user or uses some other development environment, you would probably agree

that it would be a good thing for a newlisp mode to be part of the standard emacs distribution.

----------------------------------------------------------------------------------

As soon as I have time, I'm going to add in fontera's changes and submit the revision to Lutz (unless Lutz tells me different).



To elaborate. This mode needs a PM that is a newlisp programmer, there are many fine points of the language that I am not informed of.

Furthermore, I believe that there will emerge an elegant solution to maintaining an embedded

  documentation resource from the newLISP source code documentation system, but

  that's going to necessitate someone with some newlisp knowledge.

I would be happy to support and help the new PM - I'm currently working on a major mode for rebol, and I've added numerous other features that  may translate to newlisp.



I was pleased to see that someone posted the opinion the newlisp mode is preferable to slime-mode - :-) thanks! but slime is *very* sophisticated and if I ever attain that level of expertise I'll be eating steak more and beans less. Besides, slime is a 'comint mode', not an editing mode....



Cheers everyone ....

Tim
#50
newLISP newS / newlisp docs and various editors
June 29, 2006, 09:17:59 AM
While setting up a newlisp editor mode for emacs, I wrote an

application in rebol that parsed newlisp documentation and created

elisp data structures for emacs to use.



I first 'massaged' the documentation, inserting "tags" to provide some

sort of delimiting for the parsing operation.



1)Perhaps a I missed something, so can anyone offer a method to

   parse without the 'massaging'?



2)This same method can be modified to provide .txt helpfiles for vim.

   If any vim users are interested give me a 'holler'. I used to work

   with vim a lot, but it's been a while, so I will need to refresh my

   understanding of vim helpfile layouts.



3)Perhaps the same method can be used for other editors, too.



4)For myself, I'm nowhere without documentation and like to

write same for my own libraries. Programming is an "open book test"

for me. :-)



tim
#51
newLISP newS / Emacs Editing Mode for Newlisp
June 29, 2006, 09:03:11 AM
See

http://www.johnsons-web.com/demo/newlisp/">http://www.johnsons-web.com/demo/newlisp/

for all files.



Please read 0readmefirst.txt *first*. I'm not a newlisp programmer -

yet anyway, but wanted a editor customization to start with.



Some brief testing has been done on Xemacs and GNU emacs on

linux, but not on Windows. I look forward to windows results...



Features include on-demand documentation, function indexing, syntax

highlighting and 'asynchronous inferior mode' - which means that you

can run the interpereter from within the editor and evaluate code

without leaving the editor.



For those of you not familiar with emacs, it is essentially a development

environment written in a lisp dialect (elisp). Elisp should be easy for a

newlisp programmer to pick up and consequently should present a

very extendable venue for all kinds of things.



For those of you who don't like emacs and want nothing to do with it,

I don't blame you. It is difficult to get started with, and an acquired taste.

I also use vim and have some ideas that might enhance the vim mode

(if not already implemented).



I'll post those issues as another thread (something like "newlisp docs and various editors")



For those of you who are interested in emacs, but never got going

with it for reasons as above, I would be willing to lend a hand.



I don't look at this forum regularly, so if you post any questions or

comments directly to this thread, I'll be automatically informed and can respond as best I can.



Alternatively, you can email me at tim@johnsons-web.com or

tim@alaska-internet-solutions.com
#52
newLISP newS / Newlisp editor mode for (X)Emacs - vim too
February 07, 2005, 08:49:58 AM
I've set up a newlisp mode for emacs. This mode is already

quite robust, but not well tested, and has the potential

of being a full-blown IDE.



It can host the newlisp editor, handling newlisp multi-line

commands and has full-blown on demand documentation, both

one-liners and verbose.



I'm also proposing a strategy

to easily parse data from the newlisp manual and output

name/value pairs (keywords+data) so that documentation

could also be generated from vim. I believe that boxer,

which is an awesome windows editor could also exploit

such data.



The newlisp emacs mode resources are at

http://www.johnsons-web.com/demo/newlisp/">http://www.johnsons-web.com/demo/newlisp/



This is just a beginning for me, but will make changes,

correct errors, given my time and knowledge. (See

caveats).



CAVEATS: I am a emacs newbie, and not really conversant

         with newlisp at all. That means I have only

         introductory knowledge of elisp, and virtually

         none of newlisp. This project was done in parallel

         with an emacs mode for rebol, which I am conversant

         in *and* bearing in mind that some of the same resources

         may be used for generating vim helpfiles for newlisp.

         (and see abover re boxer and other editors)

         Vim *is* my main editor at this time.



So vim users may be interested in the vim helpfile angle, and I'd

be happy to contribute. After building the helpfiles, a couple

of simple vimscript functions using <CWORD> or somesuch should

suffice.



In my mind, newlisp and emacs are a good fit, because, emacs is really

"driven" by elisp, which is (to avoid being redundant) a "lisp" language.



For those of you who are interested in emacs but have found the system

difficult or newsgroups not always helpful, I'd invite you to join up

at

  http://groups.yahoo.com/group/emacs-comint/">http://groups.yahoo.com/group/emacs-comint/



which is moderated by me. With enough participation it could be helpful

to those interested in emacs (and certainly helpful to me)



NOTE: At least on you has been using mode. Please take note that

      there has been some file name and syntax changes.
#53
newLISP in the real world / Link Fails
November 08, 2004, 03:15:03 PM
Command is:

(link "newlisp" "hw" "hw.lsp")

[tim@linus test]$which newlisp

  shows newlisp at /usr/bin/newlisp, i.e. newlisp

   is in the path.

link.lsp and hw.lsp are in the same directory

Error message is

"list or string expected : (file-info orgEx)"

(file-info "newlisp") from the command line gives

nil

NOTE: this is same whether I am user or root.

Looks like file-info is failing to return anything.



Any ideas?

thanks

tim
#54
Anything else we might add? / Load Confusion
October 24, 2004, 06:46:57 PM
According to newlisp docs 'load :

Loads and translates newLISP from a source file specified ....

... evaluates the expressions contained in the file ...

... when loading is successful load returns true



The following console session uses cgi.lsp copied as cgitest.lsp

I note that the console is unresponsive until <enter> is pressed

a second time (why is that?).

Furthermore after a second <enter> and seeing 'true, a function

contained in the file is not recognized:

Console copy follows

> (load "cgitest.lsp")



true

> (url-translate "abcdef")



invalid function : (url-translate "abcdef")



;; Does not seem that cgitest.lsp is being evaluated

;; What am I doing wrong?

thanks

tim
#55
I can't seem to get multi-line expressions to work on the command line of

the newlisp interpreter.  I'm getting a "missing parenthesis" error when I

attempt it.

What am I missing here?

Also, is it possible to evaluate or "run" a file of newlisp code from the command line.



Using RH 9.0. newLISP v.8.2.0

Pointers to docs and other threads welcome.

thanks

tim
#56
newLISP in the real world / newLisp Mode for emacs
October 10, 2004, 10:41:07 AM
I'm new to newLisp, also new to emacs. A search on 'emacs'  indicates that some

members have hacked scheme.el for newLisp. I'd like to do the same. I've parsed

keywords from newlisp_manual.html, and will attempt to hack a copy of

scheme.el myself, but I would appreciate a working copy if one is available, so

I have something to fall back on when I get totally screwed up.



Comments, docs, pointers to relevant topics are welcome.

tim