r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Janko
13-Jun-2009
[13958]
rebol can be viewed also as Lisp without parentheses.. it can edit 
it's own code/data structures without any problem... so why doesn't 
rebol have something like macros ?? :)
Ladislav
13-Jun-2009
[13959x2]
well, any Lisp-er not knowing REBOL would telly you: macros are absolutely 
necessary ;-) But the fact is, that REBOL actually *does* have macros, 
since REBOL is its own macro-language
(REBOL *does not need macros*, but ssh, don't tell LISPers, they 
would say, that you always need them)
Maxim
13-Jun-2009
[13961]
nice way to put it... I hadn't thought about it that way.
Janko
13-Jun-2009
[13962x2]
I was already thinking a little that you probably don't really need 
them since you can change/generate code structures at startup or 
"JIT" and "cache" them ... but it was just a hunch.. not something 
I could imagine all the way down ...
but are there things where you could do more without perf. penalty 
if there were macros?
Ladislav
13-Jun-2009
[13964]
perf. penalty: REBOL, due to its "philosophy", is an iterpreted language, 
which is a "performance penalty" against compiled languages, yes. 
But who cares? I have seen many compiled programs much slower than 
what I was able to write in interpreted REBOL.
Janko
13-Jun-2009
[13965]
I sometimes have some stupid ideas of changing code and blocks into 
something else but I don't have a totally clear view yet if that 
is ok to do and what would be the right way to do that.
Ladislav
13-Jun-2009
[13966]
well, it takes experience, but you are doing well, I guess
Janko
13-Jun-2009
[13967x3]
yes, I am not fanatical about straight up performance, I agree with 
you abut speeds
I have one example ... it was fun to make but all in all doesn't 
seem a good idea so I don't use it now (I think it's not really robust 
and it gives strange errors.. not 100%), I am not sure.. would classic 
macros make it more possible, this all make changes at runtime: 

any-is?: func [ 'PRE s ] [
	while [ not tail? s ] [ s: next insert s PRE ]
	any reduce head s
]
; usage
if any-is? empty? [ d-y d-m d-d title category ]
    [ print "Error some value is empty: " fail: true ]
if any-is? positive? [ apples oranges kiwis grapes ]
    [ print "There is some fruit in your fridge" ]
if any-is? [ not empty? ] [ a b ] [ print "yup" ]
if any-is? [ 5 < ] [ num1 num2 ] [ print "yup" ]
if any-is? [ 5 < length? ] [ str1 str2 ] [ print "yup" ]
(I never used Lisp or Scheme for anything serrious , so I don't know 
macros in practice)
Ladislav
13-Jun-2009
[13970]
hmm, interesting approach
Maxim
13-Jun-2009
[13971]
janko, that's a great function!
Janko
13-Jun-2009
[13972]
(well I don't know if macros would enable this at all since I change 
the runtime data (to code) and macros as I understood happen at compile 
time)
Ladislav
13-Jun-2009
[13973x3]
I must say, that I don't like the non-transparent argument passing 
method
(meaning I would use func [PRE s] as the spec instead)
moreover, you can copy the S block, if that is what causes trouble 
(which may be indeed the case)
Janko
13-Jun-2009
[13976]
Maxim: hm .. I am not sure :) .. as I said I don't use it now .. 
it just has historic value ..

Ladislav: aha.. I understan what you mean .. yes I am not sure too.. 
it's fancy but not best for clear usage
Ladislav
13-Jun-2009
[13977]
did you test it with s: copy s?
Janko
13-Jun-2009
[13978]
I am not sure what was the problem .. it's a while since I used it 
.. I just thought this function can't be good ..
Ladislav
13-Jun-2009
[13979]
then there is the inclusion problem: this algorithm is O(n ** 2), 
which is slow, but for small blocks it is probably OK
Janko
13-Jun-2009
[13980]
it works in general cases and I have it in some older code .. maybe 
errors got a little strange if datatype didn't match the PRE function 
... like empty? none ... I can take some time and test it again
Ladislav
13-Jun-2009
[13981]
yes, of course, the function has to be able to do the job for all 
data in the block
Janko
13-Jun-2009
[13982x2]
yes.. I understand that .. I thought that in such case an error was 
untiuntive .. but I tried and it looks like it should .. ok .. so 
I don't know if anything is wrong with it


>> any-is? empty? [ "asd" "Asdas" ]
== none
>> any-is? empty? [ "asd" "Asdas" "" ]
== true
>> any-is? empty? [ "asd" "Asdas" "" none ]

** Script Error: empty? expected series argument of type: series 
port bitset
** Where: any-is?
** Near: empty? none
>>
If you don't see anything massively wrong with it I will start using 
it again and I will see .
Maxim
13-Jun-2009
[13984]
the copy is a good idea though, cause if you use it for real data, 
some functions can mangle the content of the block.

I'd even do a copy/deep
Janko
13-Jun-2009
[13985]
aha.. yes .. this is true.. I will add it
Maxim
13-Jun-2009
[13986]
copy could optionally be a refinement, if you know that the test 
isn't destructive... cause copy will be a performance hit .
Ladislav
13-Jun-2009
[13987x3]
copy/deep isn't necessary, since only the top level is modified (unless 
the PRE argument isn't modifying)
(unless the PRE argument *is* modifying)
hmm, the behaviour looks strange
Janko
13-Jun-2009
[13990]
what do you mean?
Ladislav
13-Jun-2009
[13991x2]
aha, why don't you use:
any-is?: func [ 'PRE s ] [
	while [ not tail? s ] [ s: next insert s PRE ]
	any head s
]
Janko
13-Jun-2009
[13993x2]
you mean without the reduce?
if it works without it it would bebetter.. then it would also be 
lazy as any is
Ladislav
13-Jun-2009
[13995]
>> any-is? empty? [ "asd" "Asdas" "" none ]
== true
Janko
13-Jun-2009
[13996]
yes :) I noticed on that example also that it doesn't work lazy as 
any .. but I didn't know I can remove reduce
Ladislav
13-Jun-2009
[13997]
well, it's REBOL ;-). (*Don't* use REDUCE unless absolutely necessary, 
at least I do it that way)
Janko
13-Jun-2009
[13998x2]
aha, it really works as it should now
I don't know why I put it there.. did I try and somehow couldn't 
make it work or just assumed I need it
Ladislav
13-Jun-2009
[14000]
I suppose the latter
Janko
13-Jun-2009
[14001x2]
probably yes
maybe this behaviour was bugging me .. because I know I use the order 
of things in any or all a lot of times to avoid null errors and similar 
.. and any-is? always preprocessed all elements
Ladislav
13-Jun-2009
[14003]
so, now you know, why I "whine" against using REDUCE by default in 
mezzanines ;-)
Janko
13-Jun-2009
[14004x2]
:)
reduce is evil !! :)
Maxim
13-Jun-2009
[14006]
yes, especially since we can reduce on demand as we are send args 
 : -)
Ladislav
13-Jun-2009
[14007]
BTW, (shameless plug) I am using INCLUDE instead of DO from the console 
when doing scripts, since I have an extensive INCLUDE-PATH, so I 
don't have to write the directory of the script, just its name