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

#16
Ok, thanks, question was silly.
#17
Ok, I understand and agree with you, add a nil to make args properly for transposition is right decision - I can filter this nil later.



But today I found that data lost because of args not matrix:
> (transpose '((1) (1 2)))
((1 1))
> (transpose (transpose '((1) (1 2))))
((1) (1))

 transpose throw away "2".



On a 2d-matrix, transpose is reversible:
> (transpose (transpose '((1 nil) (1 2))))
((1 nil) (1 2))


May be some kind of "matrix?" predicate will be useful?


Quote from: "Lutz" Downloads for an upcoming 10.7.5 later this spring: http://www.newlisp.org/downloads1075/">http://www.newlisp.org/downloads1075/
- thank you! Hope that QA-tests is up to date.
#18
Quote from: "Lutz"Thanks for the discovery of this bug.

Fixed here: http://newlisp.nfshost.com/downloads/development/inprogress/">http://newlisp.nfshost.com/downloads/de ... nprogress/">http://newlisp.nfshost.com/downloads/development/inprogress/

Thank you for nifty tool, Lutz!

NL is my pet language.



Two more questions:

1. does
(letn (L '((1 2 3) (1 2 ))) (= L (transpose (transpose L)))) -> nil
 have the same roots? Because L is not two-dimensional matrix, there must be an exception error, no?



2. I'm newbie in compiling on Windows, so please point me to HOWTO make newlisp.exe from sources from "http://newlisp.nfshost.com/downloads/development/inprogress/">http://newlisp.nfshost.com/downloads/de ... nprogress/">http://newlisp.nfshost.com/downloads/development/inprogress/". I need MinGW?
#19
Thank you for exhaustive answer!
#20
May be I don't understand recursive comparision doing by "=", but I see no logic in this:
newLISP v.10.7.1 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
> (= '(true) '(true nil))
nil
> (= '(true nil) '(true))
true

And another case on numbers:
> (= '(1 0) '(1)) #-> true?
nil
>

Bug or feature?
#21
Trying to understand how dump work on variable which not set
newLISP v.10.7.1 32-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h
# (WindowsXP)
> (setq R '()) (time (push (dump x) R -1) 10 )(map unique (transpose R))
((5249584) (256) (5243024) (5243024) (5243024))


I get in such odd situation: RAM exhausted, error occurs, but no RAM was released and REPL still works.

See:
(setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
()

ERR: not enough memory in function dump
> (delete 'x) # more than minute for evaluation
true
> # still 2Gb RAM
> (reset)
> # no effect
> (symbols)

ERR: not enough memory in function symbols
> (dotree (s MAIN) (delete s true))

ERR: not enough memory
> (sys-info)

ERR: not enough memory
> (delete 'x) # try again

ERR: not enough memory
> (exit)

ERR: not enough memory

Nothing helps and I have to kill process.

Bug or a feature?

I mean is it points to some newlisp lack or I must be more careful with all memory-related functions?



UPD:

This crash test is reproductible:
> (setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
()

ERR: not enough memory in function dump
> (delete 'R) (reset)

 - memory released and came back to normal values,

but repeat
> (setq R '()) (time (push (dump x) R -1) 100000000 ) (map unique (transpose R))
lead to endless "ERR: not enough memory", 2Gb RAM and 50% CPU owned by newlisp.exe, and nothing helps except kill process.
#22
At first, trace usual way of interpretation:
(setq  LOG '()  row '() ) ; whole tracelog and one variable for trace REPL once
;; As I understand interpretation process, when I type a str-IN and press ENTER,

;; 1. command-event catch str-IN and can returns empty string to stop interpretation in usual way.
(command-event
 (fn (str-IN)
   (setq CE-timestamp (date (date-value) 0 "%x %X"))

   (println (list {command-event} CE-timestamp str-IN))
   (setq row '())
   (setq row (append row (list CE-timestamp str-IN)))
   str-IN
   ))

;; 2. Internally calls (read-expr str-IN) it produce expr-CMD, or nothing in case of comment or empty string.

;; 3. reader-event takes expr-CMD, it "can do transformation on the expression before it gets evaluated"
;; and can stop evaluation process by returning nil. It returns (modifyed) expr-CMD.
(reader-event
 (fn (expr-CMD)
   (setq RE-timestamp (date (date-value) 0 "%x %X"))
   (println (list {reader-event} RE-timestamp expr-CMD))
   (setq row (append row (list RE-timestamp expr-CMD) ))
   expr-CMD
   ))

;; 4. Internally calls (eval expr-CMD) -> expr-RESULT.
;; 5. Internally calls (string expr-RESULT) -> str-OUT.
;; 6. Internally calls (print str-OUT) - it show these string according to pretty-print settings.

;; 7. prompt-event calls to show prompt to signal Human that transmission is over.
(prompt-event
 (fn (ctx) ; manual: "The current context before calling the prompt-event code is passed as a parameter to the function."
   (setq PE-timestamp (date (date-value) 0 "%x %X"))
   (setq row (append row (list PE-timestamp ctx)))
   (println (list {prompt-event} PE-timestamp ctx))
   (println {Complete trace of command- reader- prompt- events: } row)
   (push row LOG -1) ; наконец, добавляем это всё в копимый LOG
   (string ctx ":" (real-path) "$ ") ; return special prompt
   ))

;; now your move, Human


Result:
MAIN:r:binemacs-25.2-i686bin$ (+1 1)
("command-event" "2019.03.30 14:14:51" "(+1 1)n")
("reader-event" "2019.03.30 14:14:51" (1 1))

ERR: illegal parameter type : 1
("prompt-event" "2019.03.30 14:14:51" MAIN)
Complete trace of command- reader- prompt- events: ("2019.03.30 14:14:51" "(+1 1)n" "2019.03.30 14:14:51" (1 1) "2019.03.30 14:14:51" MAIN)
MAIN:r:binemacs-25.2-i686bin$ row
("command-event" "2019.03.30 14:14:56" "rown")
("reader-event" "2019.03.30 14:14:56" row)
("2019.03.30 14:14:56" "rown" "2019.03.30 14:14:56" row)
("prompt-event" "2019.03.30 14:14:56" MAIN)
Complete trace of command- reader- prompt- events: ("2019.03.30 14:14:56" "rown" "2019.03.30 14:14:56" row "2019.03.30 14:14:56" MAIN)
MAIN:r:binemacs-25.2-i686bin$ LOG
("command-event" "2019.03.30 14:15:00" "LOGn")
("reader-event" "2019.03.30 14:15:00" LOG)
(("2019.03.30 14:14:44" "(setq LOG '())n" "2019.03.30 14:14:44" (setq LOG '()) "2019.03.30 14:14:44" MAIN) ("2019.03.30 14:14:51" "(+1 1)n" "2019.03.30 14:14:51" (1 1) "2019.03.30 14:14:51" MAIN) ("2019.03.30 14:14:56"
  "rown" "2019.03.30 14:14:56" row "2019.03.30 14:14:56" MAIN))
("prompt-event" "2019.03.30 14:15:00" MAIN)
Complete trace of command- reader- prompt- events: ("2019.03.30 14:15:00" "LOGn" "2019.03.30 14:15:00" LOG "2019.03.30 14:15:00" MAIN)
MAIN:r:binemacs-25.2-i686bin$


Obviously, there must ERR includes in LOG, but it can be done later, much more important check positive scenario: have a row in prompt-event try to do steps 4-5-6 parallel with usual interpretation process and compare results.

 Any feedback will be gratefully accept.

P.S. Sorry for my poor english (and poor code too :) - please do not shoot the pianist, he is doing his best.
#23
Ok, I read forum and see many post with self made REPL.

Despite of this posts dated more than five years ago, it takes away half of my fear to broke normal interpretation process :)



Problem statement: have data structure in memory like a table with columns:



     timestamp | IN | timestamp | OUT | timestamp | last-error | type-of-out | sys-info



As I understand interpretation process, when I type a str-IN and press ENTER,

1. command-event catch str-IN and can returns empty string to stop interpretation in usual way.

2. Internally calls (read-expr str-IN) it produce expr-CMD, or nothing in case of comment or empty string.

3. reader-event takes expr-CMD, it "can do transformation on the expression before it gets evaluated" and can stop evaluation process by returning nil. It returns (modifyed) expr-CMD.

4. Internally calls (eval expr-CMD) -> expr-RESULT.

5. Internally calls (string expr-RESULT) -> str-OUT.

6. Internally calls (print str-OUT) - it show these string according to pretty-print settings.

7. prompt-event calls to show prompt to signal Human that transmission is over.



(Human in turn read machine output from screen, eval (treat) result in his contexts in his mind and prints it to Machine and hit ENTER to transmit message, loop go on.)



Ok, maybe be I mistaken about steps [1-7], so try to check it out.
#24
On python I work with ipython IDE and found it very useful.

Does it possible to have for newlisp have a table of pairs:

    - IN with input command,

    - OUT with saved corresponding output

for analyse it and get useful snippets written in past?



Input can be catched in reader-event, but I have no idea how to catch output - no output-event, no $last-output variable.
#25
Quote from: "IVShilov" Two days out of luck.

Much more days out of luck, but some light illuminates the darkness.



Many (all?) UTF8-apps, starts from (in?) CMD.EXE, have problems in Windows environment (python too)



Full view about whats under the hood from (depths of) MS: https://devblogs.microsoft.com/commandline/windows-command-line-backgrounder/">https://devblogs.microsoft.com/commandl ... kgrounder/">https://devblogs.microsoft.com/commandline/windows-command-line-backgrounder/



How to force CMD.EXE fully supports UTF8 knows this guy:

1. Best answer for thread "How to use unicode characters in Windows command line?" here, briefly explain a problem: https://stackoverflow.com/questions/388490/how-to-use-unicode-characters-in-windows-command-line">https://stackoverflow.com/questions/388 ... mmand-line">https://stackoverflow.com/questions/388490/how-to-use-unicode-characters-in-windows-command-line

2. His site with solutions: https://math.berkeley.edu/~serganov/ilyaz.org/keyboard/">https://math.berkeley.edu/~serganov/ilyaz.org/keyboard/



In any case, we need functions for encoding/decoding (I still cannot import libiconv, forced use iconv.exe) and other batteries in newlisp distro like python have.

UPD: IMHO as minimum we need a prediacte (utf? str) like
(define (utf? str) (= (length str) (utf8len str)))
for figure out wait problems or not.
#26
Quote from: "ryuo"There is no built-in function that I know of that can return the type of any newLISP expression. At best, you may be able to construct your own function that uses the existing predicate functions to return a string that is unique for each cell type.

Despite of
(define (type x)
  (let (types
         '("bool" "bool" "integer" "float"
           "string" "symbol" "context" "primitive"
           "import-simple" "import-libffi" "quote" "list" "lambda"
           "fexpr" "array"))
    (types (& 0xf ((dump x) 1)))))

I have tryed to write such function, but find out that
(lambda? lambda?) -> nil
and number of other interesting paradoxes.
#27
Quote from: "oofoe"
Any possibility of getting the "(import LIBRARY)" syntax in Windows too? With maybe some way to list the symbols in the library?

Use DependencyWalker.

I see all exported functions, but still cannot understand why newlisp crashes with first call of function imported from libiconv.dll.
#28
Hello, I have a problem with importing iconv in WinXP (old notebook) - newlisp terminates right after first function call, libiconv_open.





Importing from kernel32.dll, user32.dll, works fine, but with iconv from GnuWin32 - no luck.



How can I debug FFI calls? Calling MessageBoxA without parameters ends with same process crash, but with right set of params - it works; so, maybe
(libiconv_open "cp866" "utf-8")
is wrong call?

How to certainly figure out which params and its type I have to pass to wich FFI-function?

I have "Dependency Walker" utility, maybe needs something more?



With another versions of iconv.DLL, found in system, newlisp behave like this, it crashes.
#29
newLISP newS / rotate bug on WIN7 x64
August 11, 2018, 10:52:07 AM
See this:
newLISP v.10.7.1 64-bit on Windows IPv4/6 UTF-8 libffi, options: newlisp -h

> (rotate (sequence 0 24) -25 ) # BUG:
(0)
> (rotate (sequence 0 24) -24 ) # all OK:
(24 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23)
> (rotate (sequence 0 24) -26 ) # all OK again:
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 0)
> (letn (x 25) (rotate (sequence 0 x) (- (inc x)) )) # again all OK, but must be BUG:
(26 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)
> (rotate (sequence 0 4) -5 ) # BUG:
(0)
> (rotate (sequence 0 5) -6 ) # BUG:
(0)
>
#30
Diagram is pure handmade, not script fabricated.



In cmd.exe encoding INPUT and for OUTPUT for a started process can be change by a command "chcp" (CHange Code Page, https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chcp">//https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/chcp):

> (exec "chcp")         # get current code page
("Active code page: 866")
> (exec "chcp 1251") # change code page to CP1251
("Active code page: 1251")
>
(prompt-event
 (fn (ctx)
   (string
    (last (parse (first (exec "chcp")) { }))
    { > })))

$prompt-event
1251 > # now for debugging we see chcp in prompt

For clearly understand whats going on, I use command- and reader-events:

1251 > (reader-event (lambda (ex) (println "reader-event IN: " ex)))
 => (reader-event (lambda (ex) (println "reader-event IN: " ex)))
$reader-event
1251 > (char "Ё")
reader-event IN: (char "Ё")
168
1251 > (command-event (fn (s)(println {command-event IN:} s) s))
reader-event IN: (command-event (lambda (s) (println "command-event IN:" s) s))
$command-event
1251 >

Now try "greek omega test" from newlisp manual on CP1251 and UTF-8 chcp settings:

65001 > (println (char 937))
command-event IN:(println (char 937))
reader-event IN: (println (char 937))
Ω
"Ω"

Output is good,

65001 > (println "Ω")
command-event IN:(println

ERR: missing parenthesis : "...(println"
65001 >

Looks like cmd.exe not ever passed  "Ω" to newlisp subprocess: see command-event IN:(println - string cutted.



Try CP1251:

1251 > (println (char 937))
command-event IN:(println (char 937))
reader-event IN: (println (char 937))
О©
"О©"

Output fails, and

1251 > (print "Ω")
command-event IN:(print "?")
reader-event IN: (print "?")
?"?"
1251 >

Unsuccessful too, because decoding UTF->CP1251 needed, and CP1251 have no "Ω" letter.



Two days out of luck.

Possible solutuions:

A) set cmd.exe in "chcp 1251":  

 - translate INPUT in newlisp CP1251->UTF by command-event;

 - translate OUTPUT from newlisp UTF->CP1251 by another event handler - I dont know such.

B) set cmd.exe in "chcp 65001" and figure out input translation by reading Microsoft docs.



This problem python have too: https://github.com/Drekin/win-unicode-console/tree/development#win-unicode-console">//https://github.com/Drekin/win-unicode-console/tree/development#win-unicode-console.