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 - conan

#46
I found a reference to variable $it set by setf in Introduction to newlisp book, in the chapter on strings,  http://en.wikibooks.org/w/index.php?title=Introduction_to_newLISP/Strings&stable=0#Modifying_strings">//http://en.wikibooks.org/w/index.php?title=Introduction_to_newLISP/Strings&stable=0#Modifying_strings



which doesn't exist in the manual nor works in v10.3.3.



I was about to remove the mention, but then decided to ask first in here just in case there's another way to achieve the same results. I mean to operate on the character selected by setf and use that result as the input to the same setf.



The manual only talks about $<int> and $idx
#47
newLISP in the real world / Re: no PCRE_* constants
November 24, 2011, 08:01:36 AM
Sorry about the fuss then, I shouldn't wave the bug-flag so carelessly.



I misunderstood this statement: "The following constants can be used for int-option" in http://www.newlisp.org/downloads/newlisp_manual.html#regex">//http://www.newlisp.org/downloads/newlisp_manual.html#regex , just above the table a couple of pages below the anchor.



I thought I could use them like this:



(replace {x} " x X x " {y} (| PCRE_CASELESS REPLACE_ONCE))


instead of having to do:



(replace {x} " x X x " {y} (| 1 0x800))


Quote
Many people use the numbers instead of the PCRE defined symbols.

There are not used that frequently that they should be pre defined in the newLISP executable. Decisions like that keep newLISP small.


I fully support not bloating newlisp. However I believe it's considered good practice to code like the first snippet. If asked, I'll vote for adding the constants, although I don't know the cost, they add clarity.
#48
newLISP in the real world / no PCRE_* constants
November 24, 2011, 06:32:03 AM
I found this topic:



http://newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3763&hilit=PCRE_UTF8">//http://newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=3763&hilit=PCRE_UTF8



But, I tested both v10.3.3 and v.10.3.6 by doing:



./configure && make -f makefile_linuxLP64_utf8



and I got:



$ ./newlisp -e '(replace { } " x x x " {-} 0x8000)'
"-x x x "
$ ./newlisp -e '(replace { } " x x x " {-} REPLACE_ONCE)'

ERR: value expected in function replace : REPLACE_ONCE


Also, shouldn't be REPLACE_ONCE and PRECOMPILED constants names better be prefixed with PCRE_ like the rest?



I hope it's ok to report this in this section, I didn't found any "bug reports" section.
#49
You're right Lutz... Also I think I found a bug in the installation scripts.



I downloaded v10.3.3 to check for getopts.lsp and it was right there, as you stated. So I thought it might be an error with my distro (archlinux), so I completely removed newlisp, and reinstalled it, and still no getopts module.



Then I manually downladed v10.3.3, and tried:



./configure && make -f makefile_linuxLP64_utf8 && make install_home


and no getopts module.



So I checked the Makefile and found the comment stating that makefile_install would be created differently if "make -f makefile_xxx" was used. So I cleaned up everything and started again, thinking maybe it was in one makefile but not in the other, but after:



./configure && make && make install_home


no getopts module again.



Almost finally I decided to grep:



$ grep getopt * # returns nothing
$ grep zlib * # to check for other well installed modules and see if my grepping was ok
configure-alt: -install -m 644 modules/zlib.lsp $(pkgdatadir)/modules/zlib.lsp
makefile_darwin_package: -install -m 644 modules/zlib.lsp $(datadir)/newlisp/modules/zlib.lsp
makefile_install: -install -m 644 modules/zlib.lsp $(datadir)/newlisp/modules/zlib.lsp
makefile_install: -install -m 644 modules/zlib.lsp $(HOME)/share/newlisp/modules/zlib.lsp
makefile_original_install: -install -m 644 modules/zlib.lsp $(datadir)/newlisp/modules/zlib.lsp
makefile_original_install: -install -m 644 modules/zlib.lsp $(HOME)/share/newlisp/modules/zlib.lsp
makefile_wings: cp modules/zlib.lsp /c/newlisp/modules


So there're no reference to getopts module in any makefiles.



Finally I downloaded v10.3.6 and searched again, and found no getopts reference either, though the module is in the modules directory.



On a side note, while looking at all this stuff I also found that "make install_home" didn't produce the file newlispdoc.css under ~/share/doc/newlisp/guiserver/ ;  that "make uninstall_home" didn't remove ~/share/man/man1/newlispdoc.1 ; and that the examples directory isn't installed at all, it's common to install examples under docs directory.



All this makes me think that maybe you're handling all this by hand. I don't know nothing about your development process, but I recall git has an "ls-files" parameter which can be used to automatically search for all the files needed for installation, so it's possible to devise an automated way to get all the proper files for installation. And if you're no using git, then whatever you use probably has a way to achieve the same. Just a suggestion to avoid this kind of bugs.
#50
There's no module under /usr/share/newlisp/modules/getopts.lsp yet (newLISP v.10.3.3).



Maybe the example should say that since


(module "getopts.lsp")

will not work unless you copy the module there.



Other than that, thank you Ted.
#51
Quote from: "Lutz"Yes, 'seed' will initialize the random geneartor, but actually it should have printed different random numbers the second time when this is during the same newLISP session - not after exiting newLISP and starting again. What version of newLISP, and is it 64-bit or 32-bit and on what OS, are you using?


Don't worry.



It didn't happen issuing new calls inside the same REPL session, I was reloading the script each time. I talked based on my expectations, I didn't read before what was the proper behavior. Coming from other scripting world I expected different numbers on each run of the script without the need of seeding.


Quote from: "Lutz"About arrays in newLISP: I would always start out using lists and only move to arrays when you have experienced performance problems. Then, if you change to using an array, most of your code can stay the same without any changes. In practice, I have found few programs where arrays make much of a difference.


Good to know then!



I'm just learning the language, and while I was at it I decided it would be a nice pet project for learning to make a sea battle clon. I started using associative lists, using the coordinates as keys:



(("00" nil) ("01" 2) ...)


But then things got complicated and I found arrays, so I switched.



Now I have to rethink it and switch back to list, but using them as arrays.
#52
I found that ref wants a list to search for when trying to do this:


(set 'randomMatrix (array 3 5 '(nil)))
(dotimes (x 3)
    (dotimes (y 5)
        (setf (randomMatrix x y) (rand 10))))

(ref '0 randomMatrix)


gives message:

ERR: list expected in function ref : ((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))



So I changed last line to:


(ref '0 (array-list randomMatrix))

What I was wondering is why there's no way to tell an array from a list visually from the REPL.

I get this:



> randomMatrix

((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))

> (array-list randomMatrix)

((8 3 7 7 9) (1 3 7 2 5) (4 6 3 5 9) (9 6 7 1 6) (0 2 1 8 1))



It took me some time to think they might not be the same thing internally and to discover it by asking in the REPL:



> (array? randomMatrix)
true
> (list? randomMatrix)
nil




On a side note I was expecting random numbers, but every run spits the same stuff. I realize there must be some initialization going on somewhere (didn't look for it yet). But I think most people expects random stuff to be random and when the need to make a repeatable pseudo-random stuff arise, only then use some pre-seeded function.