newLISP Fan Club

Forum => newLISP in the real world => Topic started by: conan on November 24, 2011, 06:32:03 AM

Title: no PCRE_* constants
Post by: conan on 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



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.
Title: Re: no PCRE_* constants
Post by: Lutz on November 24, 2011, 07:05:27 AM
REPLACE_ONCE and PRECOMPILED are both added by newLISP. The others starting with PCR_ are used in the PCRE documentation: http://www.newlisp.org/downloads/pcrepattern.html



These constants are not built in and when used, they often get combined using a bit-or '|'. 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.



If you find bugs, just post them here. Then everybody knows about it. If serious bugs are found in the stable release, they are sometimes announced on a special page on newlisp.org.
Title: Re: no PCRE_* constants
Post by: conan on 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 , 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.
Title: Re: no PCRE_* constants
Post by: Lutz on November 24, 2011, 08:22:51 AM
I agree that using pre-defined constants makes for much better readability and maintainability of source code. You could pre-define constants either in your program or put them in $HOME/.init.lsp