World: r3wp
[Core] Discuss core issues
older newer | first last |
BrianW 14-Jun-2006 [4847x5] | well, I know probe is the way to do it direct to stdout, but I want to save the "probe" value to a string |
and for the public record, at least part of my answer is: raw-str: mold real-str | |
yay for "source probe" | |
How about going the other way? Turning newlines into ^/ characters and so on? | |
and again I answer my own bloody question: replace/all (mold real-text) "^/" "^^/") Guess I don't actually start thinking for myself until I ask the question somewhere that I can look dumb ;) | |
Izkata 14-Jun-2006 [4852] | But that's the best way - you're more likely to remember it then! |
james_nak 15-Jun-2006 [4853] | Is there a way to "copy" an object (already defined) so the result is a distinct object? It's probably something easy but for the life of me... |
Anton 15-Jun-2006 [4854] | make |
james_nak 15-Jun-2006 [4855] | Thanks Anton. Yep, right after I wrote that I said to myself "Self, why don't you try 'd: make c [ ]'" and it works...and it is in the docs on objects. Duh. Thanks. |
Anton 15-Jun-2006 [4856] | :-) |
BrianW 15-Jun-2006 [4857] | Good to know I'm not the only one :) |
james_nak 15-Jun-2006 [4858] | You kidding? I hate it when I spend hours trying to figure out what's up. : ( |
Anton 15-Jun-2006 [4859x2] | Just remember, strings are copied, blocks are deep copied, but sub-objects are shared. |
>> o: make object! [s: "hello" b: [there] o: make object! []] >> o2: make o [] >> same? o/s o2/s == false >> same? o/b o2/b == false >> same? o/o o2/o == true | |
james_nak 15-Jun-2006 [4861] | Thanks! Sub-objects shared. Hmmm. That would have thrown me fo sure. |
Robert 16-Jun-2006 [4862x2] | This is IMO inconsistent and should be changed: >> ? for USAGE: FOR 'word start end bump body DESCRIPTION: Repeats a block over a range of values. FOR is a function value. ARGUMENTS: word -- Variable to hold current value (Type: word) start -- Starting value (Type: number series money time date char) end -- Ending value (Type: number series money time date char) bump -- Amount to skip each time (Type: number money time char) body -- Block to evaluate (Type: block) (SPECIAL ATTRIBUTES) catch throw >> a: 2.0 == 2.0 >> for test 1 a 1 [print test] ** Script Error: for expected end argument of type: integer ** Near: for test 1 a 1 >> number? a == true It should be possible to use decimal! as well. The interpreter should implicitly convert it to an integer! |
The docs state number! and not integer! | |
BrianH 16-Jun-2006 [4864] | The type of the start and end variables must be the same. If you look at the source of for, you will see that it throws that error when they are not. |
Robert 17-Jun-2006 [4865] | Yes, but 2.0 can be converted to 2, so no problem. |
Oldes 17-Jun-2006 [4866x3] | I would like to have read-thru in Rebol?Core as well |
so at least such a simple function: | |
read-thru-to: func[url target /local data loc-path][ either exists? target [read/binary target][ loc-path: first split-path target if not exists? loc-path [make-dir/deep loc-path] write/binary target data: read/binary url ] data ] | |
MikeL 17-Jun-2006 [4869] | Oldes - on true for exists? shouldn't it be "data: read/binary target" since you return :data? |
BrianH 17-Jun-2006 [4870x2] | Robert, although 1 and 1.0 are both numbers, they are not the same type in REBOL. Sure, they can be converted, but unless you do so they aren't. It would be simpler to just rewrite your example to this: >> a: 2.0 == 2.0 >> for test 1.0 a 1 [print test] 1.0 2.0 and not have the type mismatch I was talking about. Unfortunately REBOL doesn't have type signiatures that are powerful enough to specify that these two parameters need to be the same type, so that constraint has to be enforced in the code. |
Oldes, a builtin read-thru would require Core to be installed rather than just copied somewhere, just like it does with View - view-root is set during installation. Still, all of the *-thru functions are written in REBOL, so they can be copied and adapted to your purposes quite easily. | |
Volker 17-Jun-2006 [4872] | a view-root: what-dir works quite well. |
BrianH 17-Jun-2006 [4873] | See, I told you they could be adapted easily :-) |
Volker 17-Jun-2006 [4874] | :) |
BrianH 17-Jun-2006 [4875] | Personally, I always thought view-root should be under system/options somewhere. |
Anton 17-Jun-2006 [4876x2] | Robert, what are the actual numbers you need FOR for ? |
BrianH, like system/options/home ? | |
BrianH 17-Jun-2006 [4878] | Yeah, something like that. Maybe system/user/sandbox or something. For that matter, system/user/home should be set to something useful on Windows, like %userprofile% or better yet %appdata%. |
Anton 17-Jun-2006 [4879] | Oldes, Volker, I put into my rebol/core user.r file: view-root: dirize clean-path system/options/home/../view user-prefs: context [debug: none] ; fake user-prefs vbug: func [msg [block! any-string!] /local dbg][ if not dbg: user-prefs/debug [exit] msg: head insert remold msg "view " either file? dbg [write/append dbg msg] [print msg] ] along with the source to these functions: path-thru exists-thru? read-thru load-thru read-net |
BrianH 17-Jun-2006 [4880] | For that matter Volker, you could set view-root to the standard sandbox directory like this: view-root: join to-rebol-file get-env "APPDATA" "REBOL" |
Volker 17-Jun-2006 [4881x2] | Yes, but then i get security-questions. |
And i dont like to rely on user.r . personal preference. | |
BrianH 17-Jun-2006 [4883x2] | Yeah, those security questions. |
As for relying on user.r, I prefer rebol.r for things like this. | |
Volker 17-Jun-2006 [4885] | On the plugin-side it can never be secure enough ;) |
Anton 17-Jun-2006 [4886] | Hmm... should check that out. |
Volker 17-Jun-2006 [4887] | and having a %public/alongside my /core-script work quite well for me. |
BrianH 17-Jun-2006 [4888] | Sure, why not (don't answer that). |
Anton 17-Jun-2006 [4889] | I try to stay out of user.r because rebol installer has its way with it. I suspect rebol.r is also in the same category. You could lose your changes. Therefore I prefer to redirect to another script where all this action occurs. |
Volker 17-Jun-2006 [4890] | i like to poitn peoples to install rebol and run a little launch-script i send them. |
BrianH 17-Jun-2006 [4891] | No, rebol.r used to contain the feedback function and so was included in the Core package. It is not written automatically. You can keep control of it if you want. |
Volker 17-Jun-2006 [4892] | and have that run without problems. |
BrianH 17-Jun-2006 [4893] | It was supposed to be that global settings were contained in rebol.r and user-specific or local settings in user.r, but it never worked that way with Core because REBOL only looked for the location of those files once for both, rather than once for each, so you couldn't put user.r in a user-specific place and keep rebol.r is a global place. VIew does it right with version 1.3 though. |
Graham 18-Jun-2006 [4894x3] | set-net [ "[carl-:-rebol-:-com]" smtp.rebol.com ] |
should return an error ... but it doesn't. | |
as this happens | |
older newer | first last |