Some minor errors about manual and ....

Started by winger, April 06, 2012, 12:23:38 AM

Previous topic - Next topic

winger

manual
;;;;
(map (curry :area) (list (myrect mycircle))) → (200 314.1592654)


;;;;
(set 'A (array 2 3 (sequence 1 6))) → ((1 2) (3 4) (5 6))




;;;;reader-event
(context 'macro)

; registers a macro
(define-macro (macro:macro callp body)
    (push (list (first callp) '*) macro-list -1)
    (eval (expand '(define-macro callp (expand 'body)) 'callp 'body))
)

;must add otherwise will throw error when eval write express
(setf macro-list '())
;



guiserver

(gs:set-grid-layout sym-container int-columns int-rows [int-hgap int-vgap])
change to
(gs:set-grid-layout sym-container int-rows int-columns [int-hgap int-vgap])


parameter: str-down-con-path - The path for a pressed down image icon.
to
parameter: str-down-icon-path - The path for a pressed down image icon.

gs:draw-image
lost parameter:str-path



code pattern

(setf '("Anne" address city) persons '(city "Boston")) → (city "New York")
to
(setf (assoc '("Anne" address city) persons) '(city "Boston")) → (city "New York")


Many other schemes to configure a net-eval parameter list are possible. The following scheme without idle-loop would give the same results:
example code no changes


foo is the address to the structure astruc
to
foo3 is the address to the structure astruc


???
formats "u" and "d" may produce different results, because of sign expansion from 16 to 32 bits

> (setf zs "哈哈")
"哈哈"
> (pop zs -1)

ERR: not enough memory in function pop

can't pop utf-8string by index with -1


Welcome to a newlisper home:)

http://www.cngrayhat.org\">//http://www.cngrayhat.org

Lutz

#1
Thanks for all the doc corrections. All three manuals are corrected online:



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

http://www.newlisp.org/downloads/CodePatterns.html">http://www.newlisp.org/downloads/CodePatterns.html

http://www.newlisp.org/guiserver/guiserver.lsp.html">http://www.newlisp.org/guiserver/guiserver.lsp.html





But I could not repeat the UTF-8 bug, your are reporting. I tried on Mac OSX 10.7.3 and also on Windows XP SP2 using either the non-UTF-8 or UTF-8 versions of v.10.4.0. In all cases it behaves correctly


newLISP v.10.4.0 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.

> (setf zs "哈哈")
"哈哈"
> (pop zs -1)
"哈"
>


I also ran the following test code:

(setf zs "哈哈")
(println "unpack: " (unpack "bbbbbb" zs))
(println "length: " (length zs))
(if utf8len (println "utf8len: " (utf8len zs)))
(println "(char (pop zs -1)): " (char (pop zs -1)))
(println "(char 21704): " (char 21704))
(println "length: " (length zs))
(if utf8len (println "utf8len: " (utf8len zs)))

(exit)


which will produce this on UTF-8 versions:


unpack: (229 147 136 229 147 136)
length: 6
utf8len: 2
(char (pop zs -1)): 21704
(char 21704): 哈
length: 3
utf8len: 1


and this on non-UTF-8 versions:


unpack: (229 147 136 229 147 136)
length: 6
(char (pop zs -1)): 136
(char 21704): ?
length: 5


What version of newLISP and Operating System are you running.



PS: meanwhile I also tried on UBUNTU Linux 11.10 with same working results.

William James

#2

;; using sym for simulating hash tables

(set (sym "John Doe" 'MyDB') 1.234)


There should not be a single-quote after 'MyDB.

winger

#3
Quote from: "Lutz"Thanks for all the doc corrections. All three manuals are corrected online:



PS: meanwhile I also tried on UBUNTU Linux 11.10 with same working results.


Test on xp service pack 3

http://www.newlisp.org/downloads/UTF-8_win32/">http://www.newlisp.org/downloads/UTF-8_win32/ use this newlisp.exe



newLISP v.10.4.0 on Win32 IPv4/6 UTF-8, execute 'newlisp -h' for more info.


>
(setf zs "哈哈")
(println "unpack: " (unpack "bbbbbb" zs))
(println "length: " (length zs))
(if utf8len (println "utf8len: " (utf8len zs)))
(println "(char (pop zs -1)): " (char (pop zs -1)))
(println "(char 21704): " (char 21704))
(println "length: " (length zs))
(if utf8len (println "utf8len: " (utf8len zs)))

;result

"哈哈"
unpack: (185 254 185 254)
(185 254 185 254)
length: 4
4
utf8len: 2
2
(char (pop zs -1)):
ERR: not enough memory in function pop
>




and  can't use function (read-file) read  file by utf8 name.

will return nil





explode  dostring can't  correct handling of utf8 string


> (explode "我能吞下玻璃而不伤身体")
("我" "能" "吞" "下" "? "? "璃" "? "簧? "身" "体")




The following example can not be performed on newlisp 10.4.0 ut8 enable

; UTF8 example

(set 'utf8str "我能吞下玻璃而不伤身体。")

(dostring (c utf8str) (println c " - " (char c)))



25105 - 我

33021 - 能

21534 - 吞

 ...

20307 - 体

12290 - 。





ps: I think perhaps is the reason of the cmd?


> (set-locale)
("Chinese_People's Republic of China.936" ".")
Welcome to a newlisper home:)

http://www.cngrayhat.org\">//http://www.cngrayhat.org

Lutz

#4
Both example run fine here on OSX, Windows and Linux.



The character sets we are using seem to be different with different definitions


; unpack 哈哈 on your system with "Chinese_People's Republic of China.936"
unpack: (185 254 185 254)

; unpack 哈哈 on my system with ""zh_CN" or "zh_CN.GB18030" or "zh_CN.UTF-8"
unpack: (229 147 136 229 147 136)


Perhaps you can try a different Chinese locale?



Also, what happens when you run this program:

(set 'zs (pack "bbbbbb" '(229 147 136 229 147 136)))
(println (zs -1))
(println (pop zs -1))

over here it will produce:





I wonder, if your system is doing Windows MBSC or UTF-16 encoding of the command line?

winger

#5
悲催啊

> (set-locale)
("Chinese_People's Republic of China.936" ".")
> (set-locale "zh_CN")
nil
> (set-locale "zh_CN.GB18030")
nil
> (set-locale "Chinese_People's Republic of China.936" )
("Chinese_People's Republic of China.936" ".")
> (set-locale "zh_CN.UTF-8" )

(set 'zs (pack "bbbbbb" '(229 147 136 229 147 136)))
(println (zs -1))
(println (pop zs -1))

"鍝堝搱"

"鍝?

"鍝?
>
Welcome to a newlisper home:)

http://www.cngrayhat.org\">//http://www.cngrayhat.org

iNPRwANG

#6
I use the chinese locale,too. And I think that's not the newlisp's problem, because of the cmd.exe can only display characters of cp936 in general.  Write these examples in a utf-8 encoded text file and run it, will get the right result.



The "set-locale" function of newlisp is no use to change the cmd.exe's locale, if someone want to change the cmd.exe and let it can display utf-8 characters, may do like under:



1.Right click the command prompt window's caption, and click "property" on popup menu.

2.At the "Font" tabsheet, choose the "Lucida Console" font, and confirm it.

3.At the command prompt window, input "chcp 65001" command (change the codepage to utf-8).



then the command prompt window can display utf-8 characters but still has some problem, for example always display the half of the chinese character : )

winger

#7
introduction

page60



(difference d2 d1)

;-> ("." ".." ".DS_Store" "Language Modules" "Menu Scripts" "Plug-Ins"

"Read Me.txt" "Scripts" "Unix Support")

to



(intersect d2 d1)

;-> ("." ".." ".DS_Store" "Language Modules" "Menu Scripts" "Plug-Ins"

"Read Me.txt" "Scripts" "Unix Support")

======



anyone can   recommend  a console   on windows??
Welcome to a newlisper home:)

http://www.cngrayhat.org\">//http://www.cngrayhat.org