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

#1
newLISP and the O.S. / exec in newlisp 10.7.1/Windows
February 17, 2017, 10:29:34 AM
Seems like exec in newlisp 10.7.1/Windows opens it's second argument in text (as opposed to binary) mode. Test:
(exec "od -b" "hellornworldrn")
Output with newlisp 10.6.2
0000000 150 145 154 154 157 015 012 167 157 162 154 144 015 012
Output with newlisp 10.7.1
0000000 150 145 154 154 157 015 015 012 167 157 162 154 144 015 015 012
I suppose this is a side effect of the change to a newer MinGW. But still confusing - "binary mode everywhere" policy was consistent so far.
#2
newLISP newS / newlisp.vim 1.37
June 02, 2013, 12:36:22 PM
I have updated my newlisp.vim syntax highlighter; new in this version:



* all the changes made by Lutz during the last two years are adopted.



* some typos introduced by Lutz are removed (some vimscript keywords was erroneously recognized as newlisp functions because of a silly formatting error).



* $count built-in variable is recognized.



* bigint constant affix L is recognized.



* non-change: I was falsely assuming that +.9 syntax was always here, and recognize it as valid; so no need to change here (and I can pretend I've stolen the time machine from Guido).



* string delimiters (quotes and brackets) color is reverted to be the same as the string content; if you like the previous style better, put the following line in your .vimrc:



hi link newlispStringDelimiter String Delimiter



Downloadable from the usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.ru/vim/syntax/newlisp.vim">two). I believe the highlighter is ready for 10.5.1 newlisp release.
#3
newLISP newS / newlisp.vim 1.35
April 15, 2011, 12:11:23 AM
I've just realized that I haven't visited this forum for a half-year now. I am still using newLISP, just feeling less social about it. ;-) And now is the time for a new version of the syntax highlighter for the Vim text editor. This version is highly experimental, testing and feedback is highly appreciated. User-visible changes:



* String delimiters ("quotes", {braces}, and [text]tokens[/text]) are highlighted in different color than the string content.



* Bracketed symbols [like this] are highlighted in boldface; no other symbols are highlighted in boldface anymore (the newlispSymbolSpecial group is gone).



* Errors highlighting is drastically changed. The newLISP itself allows tokens to touch without  a separator, this leads to very strange code in some cases. For example, 019 is two tokens, not one (digit nine may not occur in octal literal, so it starts a fresh new number). Similarly, one[two] is one single token, but [one]two are two (check this with your newLISP interpreter!). I believe that using this feature in the real code leads to confusion, therefore the adjacent tokens are marked as errors (to be precise, the second of two adjacent tokens is marked as error, this should give you a clue why there are two and not one!). You can see some corner case examples http://slobin.pp.ru/newlisp/errors.lsp.html">here.



Downloadable from the usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two). And again, this is an experimental version, please test it before using in production!
#4
newLISP newS / newlisp.vim 1.32 (and 1.33!)
October 06, 2010, 07:53:16 PM
Another release of the newLISP syntax highlighter for the Vim text editor. A subtle bug was fixed: an unbalanced parentheses inside the font highlighting (italic or monospace) inside documenting comments was breaking the Vim built-in paren matching. Example:



;; Unbalanced paren (



was OK, but



;; Unbalanced paren '('



was not. Now the later is OK too. Downloadable from usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two). It will be helpful if someone will test this and report bugs (if any), because I am going to release the 1.33 version real soon now (next 24 hours or so), including all the new stuff from newLISP 10.2.16, in hope it will be the final release before newLISP 10.3. Thanks in advance!



If someone want to know the technical details: the Vim is very smart in parentheses matching job, it promptly skips the parentheses inside strings and comments. But strings and comments may have different syntax in different languages, so the definition is "any highlighting class whose name contains 'string' or 'comment'". In the previous versions of my highlighter, both plain comments and documenting comments does contain the word 'comment' in its name, but highlighted font sections inside doc comments was not. Now they are properly renamed.
#5
I have found this funny regexp http://www.kite-language.org/article/something-fun-to-try/">here, guess what it matches? Or check it with newLISP:
(for (i 1 100)
  (unless (regex {^1?$|^(11+?)1+$} (dup "1" i))
    (print i " ")))

Astonishing! ;-)
#6
Is it possible to run an external program (ex. notepad.exe) from newlisp on Win32, not opening a console window, and wait for it to finish? Both (! "notepad.exe") and (exec "notepad.exe") run cmd.exe first and therefore create a console window. On the other hand, (process "notepad.exe") runs notepad.exe directly, and doesn't wait for notepad to finish. And there is no wait-pid in Win32. Can I have both, please?
#7
I've tried to write the "complete" Windows application in newLISP, just as a demo, or proof of concept. I mean, with an event loop and such. The hard part is, that newlisp.exe is already a console application, and you cannot establish an event loop in console window (in fact you can, but the results are hardly predicable). So the trick is to create another window and create an event loop there. So, the application that "does nothing" is 80 LOC. It can found be http://slobin.pp.ru/newlisp/win32demo.lsp">here. It is basically a clone of a demo found http://bobobobo.wordpress.com/2008/02/03/getting-the-hwnd-and-hinstance-of-the-console-window/">here, translated form C++ to newLISP. I believe it can be a useful learning tool (it was for me definitely!). Probably I should add more comments to the code.
#8
Anything else we might add? / This forum logo
May 26, 2010, 07:41:34 AM
That is silly, but I have always interpreted this forum logo as "a fly with a flyswatter".

Not to insult anybody, just a funny self-observation. ;-)
#9
newLISP newS / newlisp.vim 1.31
May 09, 2010, 03:33:13 PM
New release of newlisp.vim syntax highlighter.



* Multiple patches (mostly new function names) by Lutz are included,



* Some typos introduced by Lutz are removed, ;-)



* Minor code cleanup.



This release is numbered 1.31, because 1.28 to 1.30 was used by Lutz. I believe it is ready for newlisp v10.3. Downloadable from the usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two).
#10
On Windows XP, somewhere between 10.2.1 and 10.2.4, attempt to get-url from a closed port became always waiting for 10 seconds, with no regard to time-out argument.


newLISP v.10.2.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (list (date) (get-url "http://localhost:8888") (date))
("Sat May 01 21:03:28 2010" "ERR: Connection failed" "Sat May 01 21:03:29 2010")


About 1 sec pause here. But:


newLISP v.10.2.4 on Win32 IPv4, execute 'newlisp -h' for more info.

> (list (date) (get-url "http://localhost:8888") (date))
("Sat May 01 21:04:45 2010" "ERR: Connection failed" "Sat May 01 21:04:55 2010")

> (list (date) (get-url "http://localhost:8888" 2000) (date))
("Sat May 01 21:05:01 2010" "ERR: Connection failed" "Sat May 01 21:05:11 2010")

> (list (date) (get-url "http://localhost:8888" 20000) (date))
("Sat May 01 21:05:31 2010" "ERR: Connection failed" "Sat May 01 21:05:41 2010")


No one process has even listen 8888 port on each case. 10.2.5 works the same as 10.2.4. I believe this is related to the new net-connect functionality in some way. Is it possible to return the old behavior, or observe a timeout parameter, or something like that? Waiting for 10 seconds is inappropriate sometimes. :-(
#11
I am trying to search through a list of the associative lists (a sort of nested context handling). I have tried to use a call to assoc function as a break condition of dolist, example code follows:


newLISP v.10.2.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> ; a sort of nested contexts
> (setq la '(((k0 v0) (k1 v1)) ((k2 v2) (k3 v3)) ((k4 v4) (k5 v5))))
(((k0 v0) (k1 v1)) ((k2 v2) (k3 v3)) ((k4 v4) (k5 v5)))

> ; we can search through them
> (dolist (x la) (println $idx ": " x ", " (assoc 'k3 x)))
0: ((k0 v0) (k1 v1)), nil
1: ((k2 v2) (k3 v3)), (k3 v3)
2: ((k4 v4) (k5 v5)), nil
nil

> ; but when we try to stop...
> (dolist (x la (assoc 'k3 x)) (println $idx ": " x))
0: ((k0 v0) (k1 v1))
?

> ; something weird already! If we try to save the result...
> (setq result (dolist (x la (assoc 'k3 x)) (println $idx ": " x)))


... the interpreter crashes!



A bug in my code, or in newLISP?
#12
In the brave Unix world, anything with an 'x' bit set is an executable, and the interpreter is determined by #! notation. In Windows, you need a real .exe file sometimes. One particular case is Windows screensavers, which in fact are .exe files with .scr extensions.


QuoteBTW, screensavers are not only to save your screens! It is just a handy way to do something useful when your computer is idle.


Of course you can link the newlisp executable with your code, but then you lose one of the advantages of scripting languages: ability to modify your code and run it immediately. Linking is too similar to compilation. :-( My solution is to link the newlisp executable with this one-liner:


(load (replace {.[^\.]*$} (main-args 0) ".lsp" 0))

, then rename the resulting executable to, say, ushaper.scr. Then copy it into your c:windowssystem32 folder, set it as your screen saver, and, on run, it will just load ushaper.lsp from the same directory. The only disadvantage is that you must maintain two files instead of one, but in fact the first one don't need any "maintenance".



BTW, "ushaper" is not just a random name, it is my small script to shape uTorrent client bandwith: give it more when you are away, get it back when you return to you computer. Source is http://slobin.pp.ru/newlisp/ushaper.lsp">here. ;-)
#13
newLISP (10.1.5 and 10.1.6 checked) failed to parse an HTTP answer if it contains 8-bit characters in headers. Well, according to RFC, there should be no 8-bit character in headers, but in real live there are. In particular, I cannot avoid them in my application (the server returning them is not under my control). Anyway, dependence of char signed-ness of C implementation is usually considered a bad style. In file nl-web.c:


/* socket send and receive routines with timeout */
int recvc_tm(int sock)
{
struct timeval tm;
char chr;

  // skipped

return(chr);
}


When 8-bit characters (I mean "which high bit set") are received from the socket, function returns a negative integer, which is treated as end-of-file later, leading to obscure error message. Replacing char chr; with unsigned char chr; has fixed the problem for me (I have compiled newLISP with MinGW under WinXP). I hope this (or similar) patch can be included in the next release. Thanks in advance!
#14
Whither newLISP? / Generic data stucture?
June 25, 2009, 03:22:11 PM
Maybe I am reinventing the wheel, but this pattern seems useful for me:


newLISP v.10.1.0 on Win32 IPv4, execute 'newlisp -h' for more info.

> (define (Struct:Struct) (apply context (cons (context) (args))))
(lambda () (apply context (cons (context) (args))))
> (new Struct 't)
t
> (map t '(year month day hour min sec micro doy dow tz dst) (now))
(2009 6 25 22 8 49 219840 176 5 2009269136 5251736)
> (setq t:year (+ t:year 1))
2010
> (t 'year (+ (t 'year) 1))
2011


A generic data structure which fields are accessible by both colon and functional notations. The later is useful for group assignment. And now I have a bunch of questions: do I reinvent the wheel? do I mislooked some caveats? can this be made simpler? does this seem useful after all?
#15
newLISP newS / newlisp.vim version 1.27
June 12, 2009, 11:28:59 AM
I've updated the newlisp.vim syntax highlighting file. In this version:



* new built-in functions introduced recently into newlisp: last-error, xfer-event and inf? (the version shipped with newlisp already has these);



* module function (technically, not built-in but preloaded, but worth highlighting nevertheless);



* custom tags for newlispdoc are highlighted (but not the same way as standard ones, to make catching typos easy);



This release is numbered 1.27, because Lutz has used 1.26 for his patched version. I believe it is ready for newlisp v10.1. Downloadable from the usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two).
#16
newLISP newS / newlisp.vim version 1.25
March 20, 2009, 05:57:58 PM
Minor update of newlisp.vim syntax highlighting file. In this version:



* Adopded changes made by Lutz in 10.0.2 (estack and read-utf8). BTW, Lutz, integer is still defined as alias of int! Do you intent to remove it, or to keep it forever?



* Another attempt to became more compatible with some 3rd party tools (which use Vim syntax files but do not understand full Vim scripting language). In any case this should not affect regular Vim users.



Downloadable from usual places (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two).



P.S. I am not deep into newlisp development now, but I'm trying to keep myself in sync.
#17
newLISP in the real world / Docomentation example?
January 19, 2009, 04:25:21 AM
Reading new Jeff's introduction to FFI, I have noted that in the documentation of import function in the newLISP manual there are examples of importing printf from the standard C library for Linux, MacOS and Cygwin, but not for standard Win32 distribution. I have noted many times before that amateur windows programmers doesn't typically know where the standard C library is located in their system. Maybe it is a good idea to give them a hint?


newLISP v.10.0.1 on Win32 IPv4, execute 'newlisp -h' for more info.

> (import "msvcrt.dll" "printf")
printf <77C4186A>
> (printf "pi = %fn" 3.1415926)
pi = 3.141593
14


Just one more line in the manual.
#18
newLISP newS / newlisp.vim version 1.24
November 26, 2008, 01:49:26 PM
Another step toward newlisp v10.0. No major changes this time, only an update of built-in functions list. In particular:



* integer is moved to "obsolete" section. It was removed from documentation long ago, and Lutz said it will be discarded completely in 9.9.96 release.



* new section "debugging" is created, it contains two functions: estack and dump-symbol. They are not compiled into normal release code, but exist in the source. Functions are highlighted in "todo" colors (the same as obsolete), but you can change this.



* two undocumented functions discovered ;-), default and bits. Lutz said the first will be documented in 10.0, how about second?



* minor code cleanup in newlispdoc supporting code, should not affect anything.



Downloadable from usual places (http://slobin.pp.ru/vim/syntax/newlisp.vim">two), peer review solicited.
#19
newLISP newS / link.lsp incompatible with 9.9.x
November 20, 2008, 01:15:30 PM
From 10.0 release notes:


Quotewrite-buffer a never-used odd symbol syntax for the string to be written has been eliminated.


link.lsp utility does use this odd syntax! Works fine after eliminating apostrophes in all three calls to write-buffer.
#20
newLISP and the O.S. / crypto.lsp and openssl for win32
September 29, 2008, 06:05:11 AM
OpenSSL is not a part of standard Windows distribution, but it is often installed by some or another open-source application. In fact I don't even know which application is responsible for the opensll library on my Windows box! ;-) And the crypto.lsp module works with it almost out of the box: you need only to add the library location to the list. That's all!


   "/usr/lib/libcrypto.dylib"
    "c:/windows/system32/libeay32.dll"
))  


Testing:


C:...ril SlobinMy DocumentsDownload>newlisp crypto.lsp
newLISP v.9.9.4 on Win32 IPv4, execute 'newlisp -h' for more info.

> (crypto:md5 "ABC")
"902fbdd2b1df0c4f70b4a5d23525e932"


Maybe it is worth to add this one line to the crypto.lsp module in standard distribution?