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

World: r3wp

[Core] Discuss core issues

Gregg
28-Mar-2006
[3850x5]
Also, WRT language docs, there is the online dictionary and the Word 
Browser in Viewtop.
As far as what is included, this is tough because everybody coming 
to REBOL will want different things, and including all of it would 
make REBOL a complete mess. Is a substring function a good idea? 
Sure; I've written a lot of them. :-) I'm still working on a whole 
*bunch* of functions that might be useful, but they are hard to design 
well, so they are easy to use, flexible, and intuitive.
Fore example In the case of "substring", that's a bad name IMO, because 
you can use the same concept on any series, not just strings. Is 
"subseries" a good name? Does it read well? Not so much. It could 
mean different things to different people (e.g. are you looking for 
nested series values?). What about "extract", ah, that's used already, 
and what are the implied semantics if we do override it and add behavior? 
I like EXCERPT myself, but it's not a nice short word that's easy 
to guess if you're not sure what it might be called. Whatever the 
name, should there be a /REMOVE refinement, or should there be a 
separate function for that?


OK, so let's assume we have a good name now, how do you define the 
bounds? There is no range! or bounds! type in REBOL. Do you just 
use lower and upper bounds, or should it take an offset and length? 
Should we define a dialect for this? If so, how flexibile should 
it be? Can you get multiple "pieces" all at once? Can you handle 
2D extractions easily and clearly? Should you? Can you specify reverse 
extractions (e.g. from the tail)? Should it return the elements in 
reverse in that case, or should it throw an error if the lower bound 
is higher than the upper bound? etc.
So, you have to do this:
	COPY/PART AT xxx 5 10
instead of
	SUBSTRING xxx 5 14
	(or maybe SUBSTRING 5 10) 


Yeah, it's a few extra characters, but it's actually pretty expressive 
and clear.
And maybe someday we'll have one, who knows.
Pekr
28-Mar-2006
[3855]
substring is easy one ... give me easy 'pad oneliner :-)
Gregg
28-Mar-2006
[3856]
Sorry, mine is way more than a one-liner. :-)
Pekr
28-Mar-2006
[3857x2]
never mind ... it is just it makes me think each time I need it. 
The same goes for float conversion to number based, not that 1-E 
ble format ....
IIRC Carl had once some formatting functions in his mind, maybe those 
would be good to have included into Core at mezzanine level?
Gregg
28-Mar-2006
[3859x2]
I can give you mine, and I do have some one-liner versions around 
I think, but I assume you already have some, and are just talking 
about having a standard one.
I think FORMAT is on many lists. That's a *really* hard one to design 
though. So many ways it could go.
Sunanda
28-Mar-2006
[3861]
. [apologies for dotting, but I can see from rebol.net that I'm not 
synced in this group]
[unknown: 10]
28-Mar-2006
[3862x3]
What is the quickest routine  in rebol to compare 2 series of values 
based on position of the value against data of the value.. i.e. a: 
[ 1 2 3 4 5 ]  b:[ 5 6 7 8 9 ]
Mmm how do i exmaplain this correctly... ;-)
How do i check If a value in serie a does occeur in b on a specific 
position ? Currently im doing that with a foreach including a for 
loop..But somehow rebol should have something buildin i thought? 
or not.. unqiue intersect and difference are not good enough for 
this...and speed is a concern too..
DideC
28-Mar-2006
[3865x2]
an exemple?
an example?
Allen
28-Mar-2006
[3867]
Rebolinth: Need you to show an example with the expected results. 
Also are A and B of fixed length or varied?
Gregg
29-Mar-2006
[3868]
Use FIND + INDEX? maybe?
[unknown: 10]
29-Mar-2006
[3869x2]
yes well find and index where not what i searched for...ill drop 
an example...hold on a few hours ;-) back ltr...
...an example...


I build in lisp a latin-square example and rebuil it in rebol.. the 
bottle neck is not the random generator

but its for me the function called 'clean? (can this function be 
exchanged with a rebol buildin funtion? or
even be made smaler?)


; a latin square in rebol

random/seed now

clean?: func [ x /local bb i ][ 

 catch [ foreach bb b [for i 1 9 1 [ if = pick bb i pick x i [throw 
 false] true ]]]]

print "---- running ----"

T1: now/time/precise
insert/only b: copy [] random/seed [ 1 2 3 4 5 6 7 8 9 ]
print first b

while [ < length? b 9 ][  

 if clean? set 'x random [ 1 2 3 4 5 6 7 8 9 ] [ print x insert/only 
 b x ]]

print rejoin [ "Timed: " now/time/precise - T1 ]

wait 0:0:5
quit
Allen
29-Mar-2006
[3871]
As a general rule, try to use native! looping functions, they are 
faster. In the above the native! "repeat" could replace the use of 
"for"
[unknown: 10]
30-Mar-2006
[3872]
talking about speed improvement!! that 'for loop is very slow compaired 
to the 'repeat ;-) thanks..
DideC
30-Mar-2006
[3873]
; Try :
	source for
	source repeat
; and see !!!
Oldes
1-Apr-2006
[3874x2]
Is there someone using a Rebol script to send IF_MODIFIED_SINCE in 
HTTP get header?
ech, I forgot I can use read/custom to set the header easily:-)

read/custom page [header [If-Modified-Since: "Sat, 1 Apr 2006 14:42:13 
GMT"]]
Anton
1-Apr-2006
[3876]
:)
Thør
1-Apr-2006
[3877]
.
Thør
2-Apr-2006
[3878]
,
Anton
2-Apr-2006
[3879x2]
Greetings Thør.
Ok I have a question.


I would like to catch an error inside a function and throw it out 
so the error position is reported "near"

the function itself. As far as I understand we should do that with 
something like this:

check: func [

 [catch]  ; <-- function spec attribute flag which changes the reported 
 position of the error.
][
	load "http://("  ; <-- cause an error on purpose
]

Now I have tried various things:

>> check: func [][load "http://("]
>> check
** Syntax Error: Missing ) at end-of-script
** Near: (line 1) http://(

>> check: func [[catch]][load "http://("]
>> check
** Syntax Error: Missing ) at end-of-script
** Near: (line 1) http://(

>> check: func [[catch]][throw-on-error [load "http://("]]
>> check
** Syntax Error: Missing ) at end-of-script
** Near: 



But none of these seems to be reporting the "Near:" position that 
I'm expecting.

(Indeed, the last one looks kind of buggy reporting to me. Anyone?)
Volker
2-Apr-2006
[3881x5]
>> check: func [][throw-on-error[load "http://("]]
>> check
** Throw Error: ** Syntax Error: Missing ) at end-of-script
** Near: (line 1) http://(
>
You need to throw the error for [catch] to see it
Hmm, that looks like one of your tries.
; usually works like this

>> check: func [[catch]][throw-on-error[1 / 0]] check2: does[check] 
check2 ** Math Error: Attempt to divide by zero
** Where: throw-on-error
** Near: check
>> check: func [[catch]][1 / 0] check2: does[check] check2
** Math Error: Attempt to divide by zero
** Where: check
** Near: 1 / 0
;but load seems really to confuse  the near:

>> check: func [[catch]][throw-on-error[load "("]] check2: does[check] 
check2 ** Syntax Error: Missing ) at end-of-script
** Near:
Anton
2-Apr-2006
[3886x2]
Yes, that's just what I was thinking.. It seems most likely that 
LOAD confused the interpreter about the "Near:" position.
So it looks like a bug to you too ? I would like to check with Ladislav, 
Romano or Gabriele.
Ladislav
3-Apr-2006
[3888]
I suggest you to put it to RAMBO
Anton
3-Apr-2006
[3889]
Ok, submitted.
Thør
4-Apr-2006
[3890]
manual resync
Jerry
5-Apr-2006
[3891]
Outer: context [
	name: "Outer"
	Inner: context [
		name: "Innter"
		get-outer-name: does [
			; I would like to return the outer name.
			; How would I do that? Thank you.
		]
	] 
]

; Making the get-outer-name function return Outer/name is not
; a good idea, since Outer can be cloned and its name can be
; changed, as follows 

Outer2: make Outer [ name: "Outer2"]
Outer2/Inner/get-outer-name

; Any help will be appreciated.
Sunanda
5-Apr-2006
[3892]
As you say, the context doesn't have a name.

it could be anonymous, or multiple words could be assigned to it, 
so there is no one "name"
outer2:  :outer
outer3: :outer2
Anton
5-Apr-2006
[3893x3]
You have to maintain a parent attribute.
>> outer: context [inner: context compose [parent: (self)]]
>> probe outer/inner/parent
make object! [
    inner: make object! [
        parent: make object! [...]
    ]
]
It works by composing the block before making it into an object. 
So self at that moment evaluates to the outer object.
When cloning the outer object, you will have to make sure to also 
clone the inner object (ie. you must implement deep recursive clone 
yourself), making sure to maintain parent correctly.
Jerry
5-Apr-2006
[3896]
Thanks. Anton and Sunanda.
JeffM
8-Apr-2006
[3897x2]
Is there any way to get the RGB data from a loaded image?
I assume there is a simple refinement to do so (like /size to get 
the size of the image), but I can't seem to find it.
Gabriele
8-Apr-2006
[3899]
>> logo.gif
== make image! [100x24 #{
252525141414141414141414141414141414141414141414141414141414
14141414141414141414141414141414141414141414...
>> logo.gif/rgb
== #{
2525251414141414141414141414141414141414141414141414141414141414
141414141414141414141414141414141414141414141414141414141414...
>> logo.gif/alpha
== #{
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000...