AltME groups: search
Help · search scripts · search articles · search mailing listresults summary
world | hits |
r4wp | 5907 |
r3wp | 58701 |
total: | 64608 |
results window for this page: [start: 46601 end: 46700]
world-name: r3wp
Group: Core ... Discuss core issues [web-public] | ||
Gabriele: 10-Aug-2010 | Agreed that the code is "Javaish"... still, hard crashes are always worth fixing, you'll never know when they're going to bite you! (Maybe Carl should do a blog post explaining why that approach is bad and what is the alternative, most people get thaught that stuff in school and don't know better.) | |
Gabriele: 11-Aug-2010 | Yes, that is a valid interpretation as well (things like that are not a good thing to do in REBOL). I do think that you can't give a more "rebolish" implementation without the context (that's the whole point of REBOL). | |
Henrik: 13-Aug-2010 | I guess it's about the propagation of NONE. If TRIM is used as part of a larger concatenated string, you could be forced to handle the NONE case after TRIM. | |
Nicolas: 14-Aug-2010 | I'm having difficulty using the find function to find an image in an image. The image specification seems to indicate that this should be fine. Is this a known issue? | |
Steeve: 14-Aug-2010 | it's broken since a while | |
Henrik: 14-Aug-2010 | because LAYOUT sets set-word!s globally. they don't exist in a particular context. | |
Gabriele: 14-Aug-2010 | or, if you want a more general solution, see my implementation of modules: http://www.rebol.it/power-mezz/mezz/module.html | |
Graham: 14-Aug-2010 | so this is like a 'funct for layout | |
Gabriele: 14-Aug-2010 | it will make set-words in there local. i think i had a refinement to also get the context in case you need to access it... | |
Gabriele: 14-Aug-2010 | (it's a small function so you can easily modify it to fit your needs, as well) | |
Graham: 14-Aug-2010 | I have a screen ( VID) and a function that loads values into that screen. I was hoping to reuse that screen elsewhere by enclosing into an anonymous context, and use the function that loads the data with the same. | |
Graham: 14-Aug-2010 | Well, instead then a context function that deep scans for all set words | |
Graham: 14-Aug-2010 | thanks .. I'll give it a go | |
Anton: 15-Aug-2010 | You can call OPEN-WINDOW several times before DO-EVENTS, or add a button which calls it. | |
Anton: 15-Aug-2010 | Gabriele's vid-context is a pretty nice function. | |
Graham: 15-Aug-2010 | why is it wrapped in a block? | |
Anton: 15-Aug-2010 | It creates new copies of the functions in window-functions each time a new window is opened. | |
Anton: 15-Aug-2010 | Ok, in that case, go back to the first example I posted. I'll need to modify it a little bit.. | |
Graham: 15-Aug-2010 | the situation is that I have a lot of screens inside tabs. now sometimes I want to re-use those screens outside the tabs ... so I just copy the code and put into a new window .. but then I want to be able to make the functions that operate on the original sceens work on my new ones. | |
Graham: 15-Aug-2010 | so I would pass the context to each function as a parameter | |
Graham: 15-Aug-2010 | So, rewrite the function to take a parameter word from the context it is to work in, and let it bind itself to that context ... | |
Graham: 15-Aug-2010 | well, I have named fields ... and a bunch of data coming in which I need to fill the fields | |
Anton: 15-Aug-2010 | You can bind directly to a context now, you don't need to pass an example word, unless you are using a very old rebol version... | |
Anton: 15-Aug-2010 | Alright, well, if you have a function which manipulates many faces, then there are arguments to be cut down, and there is a benefit. | |
Anton: 15-Aug-2010 | Anonymous, yes. ctx: context [a: 1] bind [a] ctx | |
Anton: 15-Aug-2010 | You no longer have to do: bind [a] in ctx 'self or bind [a] in ctx 'a | |
Anton: 15-Aug-2010 | Ok, so you can rewrite each of your window functions to take, and bind itself to, a context argument; or, you can add a "BIND-FUNCS" function, taking a context argument, which rebinds all your window functions to the context. Similar to what I've done above. | |
Anton: 15-Aug-2010 | From the FACE argument (eg. the newly created BUTTON face), you can climb up to the window face, then search through its subfaces for one with a word VAR facet. That word should have been already bound by VID-CONTEXT, so that means we can pre-bind the action block to the context (just before the action function is created from it). | |
Maxim: 15-Aug-2010 | binding control in R3 is one of my favorite things that got a major boost in capability. | |
Anton: 16-Aug-2010 | Here's a proof of concept for that idea I mentioned: | |
Anton: 16-Aug-2010 | svv/vid-styles/button/multi/block: func [face blk][ ; <- This only does BUTTON for now. if pick blk 1 [ ;face/action: func [face value] pick blk 1 face/action: func [face value /local window word] compose/only [ window: face/parent-face ; Find the window face <-- (simplistic for now) word: window/pane/1/var ; Find a word which references a field in the window. <-- (simplistic for now) print "Remake action function." face/action: func [face value] probe append append copy [bind-funcs] to-lit-word word (pick blk 1) do-face face value ] if pick blk 2 [face/alt-action: func [face value] pick blk 2] ; <- Also need to remake alt-action similarly to action, above. ] ] bind-funcs: func [word] [ foreach window-function [hello][bind second get window-function word] ] hello: does [f/text: copy "hello" show f] open-window: does [ view/new center-face layout ctx: vid-context [ f: field button "Hello" [hello] button "Clear" [clear-face f] ] ] open-window open-window do-events | |
Graham: 16-Aug-2010 | so when you use the action of a button, it binds the context of the first word in the action block to the current context | |
Graham: 16-Aug-2010 | if the action is to update a different window in a different context .. I guess that action would stop working .... | |
Graham: 16-Aug-2010 | and it doesn't solve the issue where the function you are rebinding actually calls a different function to update the gui | |
Anton: 16-Aug-2010 | The major side-effect is that the action of each face (eg. button, field) will remake itself the first time it is used, to insert a snippet of code to rebind the window funcs before your specified action code uses them. | |
Anton: 16-Aug-2010 | Updating a different window can still work, though, because you're going to need to reference that window anyway to distinguish it from the "current" one: | |
Anton: 16-Aug-2010 | svv/vid-styles/button/multi/block: func [face blk][ ; <- This only does BUTTON for now. if pick blk 1 [ ;face/action: func [face value] pick blk 1 face/action: func [face value /local window word] compose/only [ window: face/parent-face ; Find the window face <-- (simplistic for now) word: window/pane/1/var ; Find a word which references a field in the window. <-- (simplistic for now) print "Remake action function." face/action: func [face value] probe append append copy [bind-funcs] to-lit-word word (pick blk 1) do-face face value ] if pick blk 2 [face/alt-action: func [face value] pick blk 2] ; <- Also need to remake alt-action similarly to action, above. ] ] bind-funcs: func [word] [ foreach window-function [hello][bind second get window-function word] ] hello: does [f/text: copy "hello" show f] open-window: has [window ctx] [ window: view/new center-face layout vid-context/to [ f: field button "Hello" [hello] button "Clear" [clear-face f] button "Clear window2's field" [clear-face window2/user-data/f] ] 'ctx window/user-data: ctx window ] window1: open-window window2: open-window do-events | |
Anton: 16-Aug-2010 | No, wait a minute... that's what BIND-FUNCS is for. Currently it only affects HELLO, but you just need to add all the functions which need binding into the block: foreach window-function [hello get-data update-gui etc.] ... | |
Anton: 16-Aug-2010 | No, Gregg's first example suffered because it only did a BIND once, when the window was created. It needs to do the bind every time the button is pressed. | |
Anton: 16-Aug-2010 | So Gregg's example would work for each window as long as that window was the last window opened. As soon as you opened a new window, none of the other windows would work properly anymore. | |
Graham: 16-Aug-2010 | A concrete example would help me here :) | |
Graham: 16-Aug-2010 | and I guess is not that different to passing a context to a function as discussed above | |
Graham: 18-Aug-2010 | If I had a large numer of sorted strings, how can I most efficiently find the first string which partially matches my search string. Eg. I want search on '"find*" | |
Graham: 18-Aug-2010 | A hash doens't allow me to do a wild card search | |
Graham: 18-Aug-2010 | looks like I should try and get a hash for each first letter, first and second letter etc so I can at least narrow it down to the first 3 letters and then do search on everyone after that. | |
Graham: 18-Aug-2010 | 18,000 strings.... real time.... as each time they type a character I am presenting a list of choices | |
Gregg: 18-Aug-2010 | The example helps enormously Graham, because you said "first string" but now I see you want all matches for a given prefix. | |
Graham: 18-Aug-2010 | He doesn't have a like clause ... but I guess it could be faked | |
Gregg: 19-Aug-2010 | Graham, did you try REFORMing into a single string and using FIND/ANY? I did a quick test here and it's instant for me with 18K random "words" making a 200K string finding the last word (non-random for testing). | |
Gregg: 19-Aug-2010 | No, just a list of single-value records. :-) | |
Gregg: 19-Aug-2010 | You mean a block containing string values? | |
Graham: 19-Aug-2010 | Since it's a read only db, perhaps I could use Cyphre's compiler :) | |
Graham: 19-Aug-2010 | I'm sure that it is fast .. but I want real fast so I'm going to see if I can create a hash | |
Sunanda: 19-Aug-2010 | Graham -- consider using a Trie [that is more-or-less what skimp.r does, but the skimp data structures are badly disorted as I was struggling to find a deeply-nested block structure that did not trigger garbage collection bugs in the then-current REBOL core. (those bugs have been fixed)] http://en.wikipedia.org/wiki/Trie | |
Graham: 19-Aug-2010 | is there a port scheme for trie:// ? | |
Graham: 19-Aug-2010 | It seems to be working not too bad for me without a hash .. but I'll need to test it on a slower PC ( test inside a VM I guess ) ... | |
Brock: 19-Aug-2010 | Carl has a character by character search in Rebodex. Not sure if that is any better than what you have done. | |
Tomc: 20-Aug-2010 | G raham a suffix tree may be what tou want for trem compleation | |
Tomc: 20-Aug-2010 | a forest of trees where the words are on the path from root to leaf so at any interior node the possible compleations are the subtree the node you are on is the root of | |
Sunanda: 20-Aug-2010 | It's a type of denormalised trie: http://marknelson.us/1996/08/01/suffix-trees/ | |
Graham: 20-Aug-2010 | So, all I need is to write a function that takes my data and builds the tree ... | |
Graham: 20-Aug-2010 | There aren't that many new drugs added to the pharmacopaiea on a monthly basis | |
Graham: 20-Aug-2010 | Maybe Carl can add this as a native for find/deep :) | |
Tomc: 20-Aug-2010 | also look at prefix trees, may be a simpiler variant for word compleation | |
Chris: 21-Aug-2010 | Is there a case to be made for use/only ? >> use [a][a: 1] == 1 >> use/only [a][a: 1] == [a: 1] Replaces having to 'double bag' - >> use [a][[a: 1]] Am I missing an obvious equivalent? | |
Chris: 21-Aug-2010 | You get longer line lengths in the standard style: use [a][ [ a: 1 ] ] ; picture a: 1 being slightly more code | |
Chris: 21-Aug-2010 | vs. use/only [a][ a: 1 ] Partly it's aesthetics - but this is a language, aesthetics can be important. | |
Ladislav: 22-Aug-2010 | It still is possible to introduce just a special "double bag style", which is aesthetically acceptable, IMO (I have seen it somewhere, so it is not my invention): use [a] [[ a: 1 ]] | |
Ladislav: 22-Aug-2010 | >> f: func [] [[ [ a: 1 [ b: 2 [ ]] >> f == [ a: 1 b: 2 ] >> source f f: func [][[ a: 1 b: 2 ]] | |
Chris: 22-Aug-2010 | Gab: right, it's more difficult to visually parse, and it's ugly (two different issues, I'd say). Perhaps I need to use a 'double-bag function. | |
Chris: 22-Aug-2010 | It's also mentally uncomfortable - it feels like there should be a way to do use/only [a][a: 1] parse "this" use/only [mk][opt "t" mk: to end (probe mk)] | |
Anton: 23-Aug-2010 | The current USE does: 1. Create context of specified words. 2. Bind body. 3. Evaluate. Chris wants to be able to remove the evaluation. In a perfect world with no legacy issues to worry about, I would prefer USE to do only steps 1 & 2, and USE/DO to do all three steps. Or, a new function could be introduced (which I might name ENCLOSE or COOP) which does only steps 1 & 2. Alternatively, if there was a function which returned a context created from a block of words, eg: CONTEXTUALIZE: func [words [block!]] [ ... ] ; Returns a new context containing words without evaluation. then you could imagine using an idiom to get steps 1 & 2, or all three steps. eg: bind body contextualize words ; Steps 1 & 2. do bind body contextualize words ; All three steps. So Chris' example would be: parse "this" bind [opt "t" mk: to end (probe mk)] contextualize [mk] (<sigh> If only BIND had its argument order reversed...) | |
Maxim: 24-Aug-2010 | I'm working on a high-performance windows counter for R2. on my system, the resolution is 1 / 3500000 !!! just calling the function twice, back to back returns more than 6700 counts in difference.. which is pretty fast. | |
Maxim: 24-Aug-2010 | wow, this is so precise, I can time a single call to a native! :-) | |
Pekr: 24-Aug-2010 | good enough :-) So we finally can make a Scala killer later :-) | |
Pekr: 24-Aug-2010 | hmm, wrong group for such a discussion anyway .... | |
Gabriele: 24-Aug-2010 | Anton: see make-context in http://www.rebol.it/power-mezz/mezz/module.html#section-7 I agree that it would probably make sense to have this as a native. The common usage though is that of USE so I don't think it should be changed. | |
DideC: 25-Aug-2010 | I have a question about 'unique that could become a feature request. Somebody ask (on the french Rebol forum) how he could remove the duplicate records from this dataset : database: [ a "b" "c 1" "d" a "b" "c 2" "d" a "b" "c 3" "d" a "b" "c 2" "d" ;ligne 4 to delete a "b" "c 5" "d" a "b" "c 6" "d" a "b" "c 7" "d" a "b" "c 2" "d" ;ligne 8 to delete ] My first though was "use 'unique func". But it turns out that it can't do what I though. As usual, the doc tells nothing about that (in fact it ells pretty nothing on the func), but with the /skip refinment, it seems it only checks the first value at each skip position (so the 'a in this dataset), not all the values of the record. | |
Henrik: 25-Aug-2010 | AFAIR, this is a bug. | |
Henrik: 25-Aug-2010 | I was betting there was a RAMBO ticket. Ran into this bug earlier this year. | |
DideC: 25-Aug-2010 | It could be its behaviour (if documented), but then a /all refinment would be nice to toogle the "all fields check" (like the 'sort func one). | |
Izkata: 25-Aug-2010 | 'unique appears to be using the entire record with the /skip refinement - if it was just the first value ('a), then there would only be 1 record remaining (2.7.6) | |
Henrik: 25-Aug-2010 | added a comment about the R2 bug | |
Anton: 25-Aug-2010 | Gabriele, it would certainly be good to have your nice MAKE-CONTEXT built in. I had a strong feeling you had something like that already done. I just wish for a shorter function name. You're probably right about the higher frequency usage of USE, but I was just trying to find a way to minimize the characters typed. In my proposed alternative reality, where USE and DO USE replace MAKE-CONTEXT and USE, there would be a saving in typing only if DO USE was used less than 3 times as often as USE (ie. < 75% of the time). If I could show that, then my alternative reality would at least have some typing advantage. I don't have much hope of that, so I withdraw. I'd be very happy with your MAKE-CONTEXT built in, anyway. | |
shadwolf: 25-Aug-2010 | can't it be easyer to have a delet function that will delet the 4th and 8th entry (but once the 4th entry is deleted then ... the 9th entry become the 7th entry) i was always suprised that in the list management it was easy to add sort locate information in a list but so painfull to be able to simply remove a record... (anyway if each "line" would be stored in a subblock it would be easier to remove them as line) | |
Will: 26-Aug-2010 | hello, is there a BUG or what I'm I doing wrong? extract [#[false]] 2 ; [none] extract [#[false] 1 2 3] 2 ; [none 2] | |
Will: 26-Aug-2010 | I want a false, not a none ! Thank you 8-) | |
Henrik: 26-Aug-2010 | looks like a bug to me. | |
BrianH: 26-Aug-2010 | It's a bug. Scheduled to be fixed in 2.7.8 - fix already submitted, and in R2/Forward. Submitted for R3 as well. | |
Will: 26-Aug-2010 | Thank you, do you have a link where I can get the pathced version ? | |
Will: 26-Aug-2010 | humm ok I'll check how to browse R3 chat later, Now if you could paste a copy of extract here I would be very thankfull 8-) | |
BrianH: 26-Aug-2010 | Here's the R2 version: extract: func [ "Extracts a value from a series at regular intervals." [catch] series [series!] width [integer!] "Size of each entry (the skip)" /index "Extract from an offset position" pos "The position" [number! logic! block!] /default "Use a default value instead of none" value "The value to use (will be called each time if a function)" /into "Insert into a buffer instead (returns position after insert)" output [series!] "The buffer series (modified)" /local len val ][ if zero? width [return any [output make series 0]] ; To avoid an infinite loop len: either positive? width [ ; Length to preallocate divide length? series width ; Forward loop, use length ][ divide index? series negate width ; Backward loop, use position ] unless index [pos: 1] either block? pos [ if empty? pos [return any [output make series 0]] ; Shortcut return parse pos [some [number! | logic! | set pos skip ( throw-error 'script 'expect-set reduce [[number! logic!] type? get/any 'pos] )]] unless into [output: make series len * length? pos] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [forall pos [ if none? set/any 'val pick series pos/1 [set/any 'val value] output: insert/only output get/any 'val ]] ][ unless into [output: make series len] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [ if none? set/any 'val pick series pos [set/any 'val value] output: insert/only output get/any 'val ] ] either into [output] [head output] ] | |
BrianH: 26-Aug-2010 | Here's the R3 version: extract: func [ "Extracts a value from a series at regular intervals." series [series!] width [integer!] "Size of each entry (the skip)" /index "Extract from an offset position" pos "The position(s)" [number! logic! block!] /default "Use a default value instead of none" value "The value to use (will be called each time if a function)" /into "Insert into a buffer instead (returns position after insert)" output [series!] "The buffer series (modified)" /local len val ][ ; Default value is "" for any-string! output if zero? width [return any [output make series 0]] ; To avoid an infinite loop len: either positive? width [ ; Length to preallocate divide length? series width ; Forward loop, use length ][ divide index? series negate width ; Backward loop, use position ] unless index [pos: 1] either block? pos [ unless parse pos [some [number! | logic!]] [cause-error 'Script 'invalid-arg reduce [pos]] unless output [output: make series len * length? pos] if all [not default any-string? output] [value: copy ""] forskip series width [forall pos [ if none? set/any 'val pick series pos/1 [set/any 'val value] output: insert/only output :val ]] ][ unless output [output: make series len] if all [not default any-string? output] [value: copy ""] forskip series width [ if none? set/any 'val pick series pos [set/any 'val value] output: insert/only output :val ] ] either into [output] [head output] ] | |
BrianH: 26-Aug-2010 | This bit in the R2 version (twice): ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] is I think left over from trying to optimize away the FORSKIP and FORALL from the R2 version using PARSE. That approach was rejected a couple years ago, so those lines could be removed in theory. FORALL and FORSKIP are native in R3, as all loop functions must be for now. | |
Anton: 27-Aug-2010 | It's a zero sized box, right? | |
Anton: 27-Aug-2010 | No point can be in a zero sized box. | |
Graham: 27-Aug-2010 | methinks that within? should take, integers, pairs and triplets so integers for a one dimension, pairs for two dimensions and triplets for 3D | |
Graham: 27-Aug-2010 | and maybe take an optional function if you want to supply a sphere or other volume | |
BrianH: 27-Aug-2010 | Anton, points have zero size. A zero-size rectangle could contain in theory one point. The question is whether WITHIN? is inclusive of that last point or not. | |
Gabriele: 30-Aug-2010 | Should this be considered a bug? (R2) >> b: reduce [:print :insert :read :+] == [native action native op] >> find b :print == none >> find b :insert == [action native op] >> find b :+ == [op] >> find b :read == none >> :print = :print == true >> :print = :read == false |
46601 / 64608 | 1 | 2 | 3 | 4 | 5 | ... | 465 | 466 | [467] | 468 | 469 | ... | 643 | 644 | 645 | 646 | 647 |