World: r3wp
[Core] Discuss core issues
older newer | first last |
amacleod 7-Jun-2009 [13942x4] | 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 [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 [13991] | aha, why don't you use: |
older newer | first last |