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

World: r3wp

[Core] Discuss core issues

Sunanda
7-Jun-2009
[13919]
'alter was always a poor choice of name -- short for 'alternate apparently, 
but too short to be obvious.
Anton has suggested 'toggle as a better name for it.
Graham
7-Jun-2009
[13920x3]
toggle implies something is always there ... but in a different state. 
 Swap is to imply that something goes in and out :)
Rotate is another possibility
Never had the need to use this word though :)
Henrik
7-Jun-2009
[13923]
I've used ALTER once for user selection in a list, and it was even 
a special case. I think having the ability to just conditionally 
append to a block if the value does not exist is more useful. I.e. 
an ALTER, split in two functions.
Graham
7-Jun-2009
[13924x2]
Trying to think of where I could use this function ...
>> a: [ b b c d ]
== [b b c d]
>> alter a 'b
== false
>> a
== [b c d]
Sunanda
7-Jun-2009
[13926]
'alter is a hard one to name. The operation is:

 *   if the target value exists in the series: remove the first instance 
 of it
 *   if it does not exist in the series: append it to the end.

The "remove first instance"  makes it more generic than rotate/swap/toggle 
when there is more than one instance of the target in the series.
Chris
7-Jun-2009
[13927]
flag/deflag ?
Sunanda
7-Jun-2009
[13928]
'cull almost works :-)

An english defintion being: "To take someone or something (from somewhere)."
Chris
7-Jun-2009
[13929]
'cull would be a great name for 'remove-each : )

cull deer herd [deer = not smart]
BrianH
7-Jun-2009
[13930x2]
ALTER is still in R3, though its usefulness is so limited it may 
be moved to R3/Plus. The enhanced logic flags that were supposed 
to replace it were removed in the latest release - they were never 
refined or documented to the point of being useful.
In theory, ALTER is a set function, so the series in question is 
not supposed to have duplicates.
Sunanda
7-Jun-2009
[13932]
You are quite right -- 'alter is still in R3 ..... My mistake.


Several of REBOL's set operations operate on series. Series are more 
like bags than sets, hence they can have duplicate values. That adds 
value for a programmer, but dilutes academic purity.


Perhaps 'alter could have a purer set defintion by becoming a no-op 
if the target value exists more than once in the series.
amacleod
7-Jun-2009
[13933]
Is there a way to adjust computer time from rebol?
Graham
7-Jun-2009
[13934]
'call
amacleod
7-Jun-2009
[13935x4]
you are a real tease, Graham.
I thought it might be some registry stuff
I saw some third party tools to do it but they are nearly  half meg 
in size and I thought one line of rebol might do it..
Why is the time zone displayed by rebol 'now not changed when I change 
the time zone on my computer in date and time properties?
Chris
7-Jun-2009
[13939]
Should be correct in its offset from UTC/GMT?
amacleod
7-Jun-2009
[13940x6]
No matter what I change the rime zone to on the computer I get a 
rebol time with -4:00
Just discovered that allnew instances of rebol consol produce new 
zone. I guess the consol reads zone info at start but not at each 
time get..
Got it..thanks Graham...


Here are three lines that adjust the time zone and time of the local 
computer after checking time with a server with a daytime server 
running:


call "RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z Eastern 
Standard Time"
a: to-date read daytime://myserver.com b: a/time
call rejoin ["time " b]
I guess it might be off by a second or less ...close enough
Rebol does not update changed time zone...Anyone know how to do this...I 
do not want to resart the application after the change just to get 
the new time zone..
also, change date:

call "date 6/7/2009"
Graham
8-Jun-2009
[13946x2]
http://www.fm.tul.cz/~ladislav/rebol/nistclock.r
I originally hard coded one time server into my program as in Ladislav's 
example, but I had the misfortune of that time server being out of 
action for a few weeks which introduced a 30 second timeout when 
my program started up.  Now i adjust the timeout to a much shorter 
value, and randomize from a pool of time servers.  And then restore 
the timeout value.
amacleod
8-Jun-2009
[13948x2]
I'll be serving time from the same server hosting the MYSQL DB..so 
if timeserver is down its irrelevant as they will not be reaching 
hte DB either...
and its data syncronizing that I'm concerned with...
amacleod
10-Jun-2009
[13950x3]
What am I doing wrong here??
given a block of blocks: 
[

[67 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.1"]

[69 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.3"]

[68 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.2"]

[71 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.2"]

[268 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.2"]

[721 "FFP Vol.2 - BASIC ENGINE OPERATIONS" "Chapter 1 - INTRODUCTION" 
"1.2"]
]

Using alter to remove each block in a loop:
 foreach z a [alter a reduce [z] probe a wait 3]

with a being the blocks above
It seems to work for the first two but than skips a block and than 
fails...
same result using find-remove:

foreach z a [if find a reduce [z] [remove a reduce [z]]]

I get three left over blocks


i I run it again I get one left over block and f I run it a final 
time it reoves the final block
Izkata
10-Jun-2009
[13953x2]
foreach will advance to the next index whether or not the series 
was modified:
>> D: [1 2 3 4 5 6 7 8 9]
== [1 2 3 4 5 6 7 8 9]
>> foreach X D [remove find D X]
== []
>> ? D
D is a block of value: [2 4 6 8]
Using remove-each is better for this:
>> D: [1 2 3 4 5 6 7 8 9]       
== [1 2 3 4 5 6 7 8 9]
>> remove-each X D [integer? X]
== []
>> ? D
D is a block of value: []
amacleod
10-Jun-2009
[13955]
I'm a dope...Thanks for the clue...
I used another 'variable' to what I needed...it works now!
Gregg
11-Jun-2009
[13956]
Modifying a series you're iterating over is always risky. Not only 
do you have to make sure you get it right, but there is always a 
possibility that iterators might change their behavior.
Janko
13-Jun-2009
[13957x2]
...
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
[13967x2]
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" ]