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

#21
newLISP and the O.S. / Newlisp on ASUS Eee PC 900
November 19, 2008, 12:49:12 PM
Hi:

Has anyone had any experience building and using Newlisp

on the ASUS Eee PC 900?

It has a xandros linux OS, gcc is not in the factory install,

I believe, but is available.

This link should give a look at the little fella....

http://www.amazon.com/Display-Intel-Mobile-Solid-State/dp/B001BYB60W/ref=wl_it_dp?ie=UTF8&coliid=I1LWNM4XK03I86&colid=2W50K6F8Z1QO4">http://www.amazon.com/Display-Intel-Mob ... 0K6F8Z1QO4">http://www.amazon.com/Display-Intel-Mobile-Solid-State/dp/B001BYB60W/ref=wl_it_dp?ie=UTF8&coliid=I1LWNM4XK03I86&colid=2W50K6F8Z1QO4

thanks

tim
#22
newLISP newS / FOOP Links
July 24, 2008, 01:52:57 PM
I'm going to be traveling, leaving tonight. Will have some time

to do a little R&D, but with limited Internet access.



I'd like to bone up on FOOP, especially the new approach with the

colon operator. I have the current newlisp manual on my laptop, and

if anyone could provide any other links, tutorials, examples etc -

that could be relevant I would appreciate it.



thanks

tim
#23
There seems to be a problem with the use of the C MySQL API to

escape query strings in some of the newlisp code that I have looked at.

In the mysql5 module that comes with the distribution and also in Jeff's

own modifications, I am finding the following form in the (escape)

procedure:

(set 'safe-value (dup " " (+ 1 (length value))))

If you examine this, all this does is allocate a blank string with one more

byte than the source. There should be enough bytes to escape _all_

characters (factor of 2)- if necessary, plus a byte for the terminating

NULL byte that is standard for C. I.E. length*2+1

unless I'm wrong, the form should read:

(set 'safe-value (dup " " (+ 1 (* 2 (length value)))))

This provides the C function with twice the allocated bytes of

the source, plus a byte for the terminating NULL.

My modification shows predictable results, the original code

resulted in much strange behavior. :-)

references:

http://dev.mysql.com/doc/refman/5.1/en/mysql-real-escape-string.html">http://dev.mysql.com/doc/refman/5.1/en/ ... tring.html">http://dev.mysql.com/doc/refman/5.1/en/mysql-real-escape-string.html

Tim

(an 'old '(in more ways than one) 'C dog)
#24
newLISP newS / -w switch
May 28, 2008, 02:50:41 PM
Using the following shebang line:
#!/usr/bin/newlisp -w /home/tim -c
;; with .init.lsp at /home/tim
(load ".init.lsp")

returns the following error message

problem accessing file in function load : ".init.lsp"

While
(load "/home/tim/.init.lsp")
is sucessful.

Sorry, but I don't understand, The documentation says:

"All file requests without a directory path will now be directed to the path specified with the -w option"

Also (println (directory)) shows the files

from the home directory for the script.

Same problem whether I run from the command line or

as CGI script.
#25
I've written a newlisp application that uses the mftp module.

I've integrated the same into my IDE and project manager. I used this

application to force a full update of one of my client projects.



In one execution of the application, 11 different connections were

made. From 5 to 25 files were transfered on each connection

with a total of about 165 transfers.



This tells me that cormullion did a heck of a good job and also

confirms that the native socket functions of Lutz's were working

flawlessly.



Good work!

Thanks

Tim
#26
newLISP newS / load sym-context problem
May 17, 2008, 03:53:56 PM
I have a file created by 'save. session.lsp
(context 'g)
(set 'action "Viewing file: testcgi.dbg")
(set 'home "/home/http/run/newlisp")
(set 'log-ex '(".dbg" ".err" ".ok"))
(set 'target-file "testcgi.dbg")
(set 'top-dir "/home/http/run/")
(context 'MAIN)

When I attempt to load this file without the option sym-context parameter,

all is good:
> (load "session.lsp")
MAIN
> g:top-dir
"/home/http/run/"

When  I load with 'sym-context I expected the symbol to contain

all members and values as the original but the following is not what I expected.

> (load "session.lsp" 'gg)
MAIN
> gg:top-dir
nil
> (symbols 'gg)
(gg:g gg:top-dir)

 I guess I need some clarification.

FYI: What I want to be able to do is

save variables from a session, reload them at

the next execution of the script without overwriting the

current variables.

Thanks

Tim
#27
I have a context called 'cgi and a default function as in

(define (cgi:cgi) ;....
  )

Another function in this context executes the following:
(if (not (context? cgi key))
  (raise (append "key: ['" key "] not previously set")))

Where 'raise is another function in the context.

And I get the following error message
context expected in function context? : cgi:cgi
Is there a way around this?

thanks

Tim
#28
I just got the "Reasoned Schemer".



The code that supports the lessons in the book are at:

http://sourceforge.net/project/showfiles.php?group_id=99654">http://sourceforge.net/project/showfile ... p_id=99654">http://sourceforge.net/project/showfiles.php?group_id=99654



I'd welcome comments on how difficult it might be to port

the kanren code to newlisp.



On a scale of 1 to 10? :-)

thanks

Tim
#29
newLISP newS / Return a context from a function
May 09, 2008, 06:17:48 PM
I'd like to have a function that creates and returns a new context from an existing source context:
(context 'hash)
(setq context-name "hash"    ## name of context
 object-name  "[none]"  ## name of object
 lst '()                ## list - may be nested
 )
(context 'MAIN)
(define (Hash! l oname)
  (local (newhash)
(set 'newhash(new hash 'newhash))
(println "newhash = ["  newhash:lst "]") ;; DEBUG newhash
(if l (set 'newhash:lst l))
(println "newhash = ["  newhash:lst "]") ;; DEBUG newhash
(if oname (set 'newhash:object-name oname))
(println "newhash = ["  newhash:object-name "]") ;; DEBUG newhash
newhash))

I evaluate the following with result:
> (set 'y (Hash! '((name "tim")) "myhash"))
newhash = [()]
newhash = [((name "tim"))]
newhash = [myhash]
newhash

And then evaluate 'y with (obviously) not the results I'm looking for.

> y:lst
?
> y:object-name
?

Help and examples are welcome. I haven't been able to find any

examples of this specific topic in documentation.

Thanks

Tim
#30
When I execute the following:
(set 'lst '(
    (id001 (name "Anne") (addr (country "USA") (city "New York")))
    (id002 (name "Jean") (addr (country "France") (city "Paris")))
))
(set 'myargs '('id002 'addr))
;; ('id002 'addr)
(set 'allargs (append '(lst) myargs))
;; (lst 'id002 'addr)
(apply assoc allargs)

I get list expected in function assoc : ''id002
Whereas
(assoc (lst 'id002 'addr))
Yields the expected result.

What is the correct way?

Thanks

Tim
#31
Let's say that I want a 'standard library' with functions available

globally and I _don't_ meself to mistakenly futz with these functions.



Here's what appears to work:

(set 'f '(putb ltrim ltrims)) ;; previously 'defined functions
(apply global f)
(apply constant f)

Brief tests seems to support that this works, but I would welcome

any comments, caveats or other ways to do this.

Thanks

Tim
#32
I have backgrounds in both rebol and python - which compare I suppose -

as do common lisp and newlisp in terms of scoping rules.

Be that as it may - I've seen arguments ad naseum about dynamic vs lexical

scoping - but what I'm really interested in how to use newlisp scoping to

my advantage.



I find that I've been using 'let a lot - and maybe more than I should.

So I would welcome comments, caveats, rules of thumb, etc on how

to take advantage of dynamic scoping. I've not used 'local at all.

Would be great to see further comment on that function - there's not a

lot about it in the manual.



Thanks

Tim
#33
Hi:

It is a practical matter for me, that when I use FTP programmatically, that

I frequently to multiple uploads.

To that end, I have made the following changes to the ftp module,

(define (transfer user-id password host subdir file-names mode)
  (if (string? file-names)(set 'file-names(list file-names)))

as the first two lines of function 'transfer

and the following change to the 'PUT option:

(if (= mode PUT)
        (and
(dolist (file-name file-names)
(println "<BR>file-name = "  file-name) ;; DEBUG file-name
(check-file file-name)
(net-send socket (append "STOR " file-name "rn"))
(send-get-result "STATrn" "1")
(println "opening file")
(set 'fle (open file-name "r"))
(while (> (read-buffer fle 'buffer 512) 0)
(if debug-mode (print "."))
(net-send socket2 buffer 512))
(close fle)
(println "file closed")
)) true)

I then make the following function call:
 (set 'FTP:debug-mode true)
  (set 'res(FTP:put "*user*" "*pwd*" "www.johnsons-web.com" "/demo/newlisp"
'("usr.lsp" "testcgi.dbg"))

The results follow:
file-names = ("usr.lsp" "testcgi.dbg")
sent:USER *user*

331 Please specify the password.

sent:PASS *pwd*

230 Login successful. Have fun.

sent:CWD /demo/newlisp

250 Directory successfully changed.

sent:TYPE I

200 Switching to Binary mode.

sent:PASV

227 Entering Passive Mode (12,24,138,43,204,222)


file-name = usr.lsp
sent:STAT

150 Ok to send data.

opening file
........file closed

file-name = testcgi.dbg
sent:STAT

The result is that the transmission "hangs" after the first

send and prior to the second call to 'open

:-) If we get this one working, I promise not to hack any more

of Lutz's code for at least a week or until I learn a bit more about

TCP/IP

Thanks

Tim
#34
Hi Folks:



Just tried out the smtp interface for newlisp and it is the easiest that

I've used. It would be helpful however to have information in parsing

the response string to trap errors. If anyone can point me in the right

direction, I would appreciate it. I.E. Should I always expect to find

the response code as the beginning of the response string?



Rebol and python throw errors if a successful transmission is not

 accomplished. I can observe that a successful transmission returns

221 at the head of the response string.



In addition - although I can sidestep using any SMTP server that requires

authentication - I think it would be very valuable to be able to send

authentication parameters. I've found one thread in this forum on this

matter, but couldn't find a conclusion. Again, I would welcome comments.



thanks

tim
#35
Haven't time to fully digest this thread, but it may be

of interest to others.



The subject says it all, but I could add that no one

(so far) in the newsgroup has started foaming at the

mouth at the simple mention of newlisp. :-)

Cheers

Tim
#36
newLISP newS / Compiling newlisp on ubuntu
March 15, 2008, 10:45:56 AM
Just a quick tip - to compile newlisp on ubuntu the

libc6-dev package is needed for the header files at

/usr/include. If libc6-dev is missing you will see references

to files such like stdlib.h, stdio.h, as missing.



apt-get install libc6-dev will do it.

Or get it via adept manager.

 

If newlisp were included in the ubuntu repositories,

that might contribute to more exposure, and provide

for automatic updating. I'm happy to compile, but

others might like that....

MTCW

Tim

P.S. Darn, this should be in newLISP for *n?x section. Sorry.

tj
#37
newLISP newS / Convert list to variable arguments?
March 11, 2008, 06:15:02 PM
Let's suppose I have a function foo
(define (foo)
    (doargs (i) (println i)))

and I can process it by something like this:
(foo a b c x e f g)

Now, suppose I have a list that looks like this:
(set 'lst '(a b c x e f g))

Is there a method to pass 'lst to 'foo so that it is consumend

one item at a time by 'doargs?

Thanks

tim
#38
Example:

I have written my own cgi context. It has a number of control

variables (think symbols)

I want to - if necessary customize those symbols on startup.

I have a context method call 'on.

;; Intialize the CGI object
(cgi:on 'cs nil 'placeholder true) ;; assumes that 'cs and 'placholder
                                              ;; are already defined

Inside of the 'on method, a helper function called 'parse-args

intercepts args and processes them two at a time as follows:

(define (parse-args)
 (let((key)(val))
   (dolist (item (explode (args)))
  (set 'key (last(parse(string(first(first item)))":")))
  (set 'val(second(first item)))
  (set (sym key) val))) ;; reset the symbol
 )

As written, I may mistakenly submit a symbol that is not predefined

in the context. I would like to be able to test whether that symbol

is already defined and throw an error if not. I like error messages!

I'd welcome some suggestions on how to proceed.

Thanks

Tim
#39
newLISP newS / Newlisp Coded in Java?
February 23, 2008, 04:09:07 PM
I know of some long-time java programmers who are switching to jython.

FYI: jython is python written in java and gives access to java resources

keeping the more compact python syntax.



As a long-time python programmer who is learning newlisp in my

spare time, I think I'm going to find newlisp more efficient LOCwise

than python - just as rebol is more efficient LOCwise than python.



LOC = lines of code



Therefore, it behooves me to ask:

What about a newlisp written in java?

And the newlisp binary on linux is about 15% the

size of the python 2.5 binary with, I assume similar

comparisions in the LOC.



Inquiring minds want to know.... :-)

Tim
#40
newLISP newS / Need documentation on documentation
February 11, 2008, 06:46:39 PM
Hi:

I can't locate Lutz's documentation on how to set up comment

syntax so that documentation can be generated. Can someone

point me in the right direction?

thanks

tim