• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp5907
r3wp58701
total:64608

results window for this page: [start: 45801 end: 45900]

world-name: r3wp

Group: Core ... Discuss core issues [web-public]
Terry:
8-Jan-2010
If it was a smple matter of replacing variables with values.. i have 
some °7° code that does that.
The problem is well formed javascript to send back to the DOM.
Henrik:
9-Jan-2010
From all this, the easiest way would be to produce a dialect that 
does its own escaping, so you don't have to write JS at all.
Henrik:
13-Jan-2010
does anyone have a rebol based bracket checking tool? preferrably 
something that can be integrated into a diagnostic tool.
Maxim:
14-Jan-2010
after a decade I still find new language tricks.  I call it the "temporary 
newbie moment" phenomenon... I've never had these moments in other 
languages.


its like finding a new trick to make your lego stuff stronger while 
having the same shape  ;-)
Steeve:
15-Jan-2010
is that less readable than a comnination of any/all/case/if ?
And you can align your code. 
CASE hase the most readable structure for complex tests
Why should have demonstrate such obvious thing ?
;-)

fail: [none]
case [
	not mark: find myline "text" 	fail
	4 <> length? mark 				fail
	...

]
Steeve:
15-Jan-2010
Back in time digression...


I have often noticed that it is unemployed as a method for complex 
testings.

In general it's faster and more easily readable than a serie of nested 
if / else.

But to do such, the programmer must know how testings can be complemented 
and other simplification technics.

The novice programmers (whatever the language) often find it difficult 
to do it correctly.

This is probably a gap in computer education. We don't learn anymore 
the basics of Boolean algebra.

At least for me it is an important criterion to determine the general 
level of someone in computer sciences. 
If I see too many nested if / else in a program.
I think the personn lacks of solid foundations in programming.
Maxim:
15-Jan-2010
and either in a compose is very powerfull... cause it allows conditional 
serie content creation).

; when false, an empty block is returned and compose ignores it.

draw-blk: compose [ (either gfx? [ [pen black circle 30x30 ][    
[ ]   ])]


this example is simple but when creating very complex draw blocks 
on the fly, I often have a few cascaded compose blocks, and in some 
cases, the resulting draw block is an empty block even if it takes 
100 lines to get to that.  the language will skip the nested composes 
if an outer condition is false, so in fact, its VERY fast.
Maxim:
15-Jan-2010
oops missing a "]" bracket in the above.
Maxim:
15-Jan-2010
to have conditional data creation code INSIDE the data is not something 
you see in other languages.  its usually a mess of conditionals which 
try to cover all possible permutations, as you explain... 


here, there is no need since the data's structure itself will represent 
all conditions naturally and directly.


changing the structure of the data doesn't require code rewriting 
cause they are one and the same.
Ashley:
15-Jan-2010
The optimization I really like is:

	if i = 1 [j: 2]

with:

	all [i = 1 j: 2]

when I'm reading code it seems to parse in my brain better:


 "if i equals 1 ... then ... j becomes equal to 2" vs "i equals 1? 
 j becomes equal to 2"

blocks seem to introduce a mental "pause" when I read code.
Ashley:
15-Jan-2010
Faster according to Carl. I think he had a blog entry on this one. 
Something to do with "all block" being more efficient than "if cond 
block".
WuJian:
15-Jan-2010
learned a lot :)
BenBran:
15-Jan-2010
If 
length? none! 
returned none my code would have looked much cleaner
quite a good discussion though.... learning a lot. Thanks.
Maxim:
15-Jan-2010
these are the tidbits we learn along the way.

there seem to be a few common milestones....  when you get to "grasp" 
that words aren't variables... that is usually one of the first big 
ones... and the big one is when you understand what/how binding really 
works.
Maxim:
15-Jan-2010
realizing that a block can hold [ a a a ] and yet each 'a  is actually 
a different value.  ;-)
Gregg:
15-Jan-2010
I think it was Gabriele, or maybe Ladislav that long ago posted an 
INDEX?? function that was "safe". i.e. it wouldn't crash given none. 
There's nothing stopping you from replacing LENGTH? with your own 
version, or creating a LENGTH?? func. 


There are tradeoffs of course. What may seem to make this particular 
piece of code cleaner may have a far reaching impact on other code. 
I don't always agree with Carl's design, but whenever I think he 
did something wrong, particularly early in my REBOL career, I later 
decided he was right. I still think he's wrong about a few things 
though. :-)
Maxim:
15-Jan-2010
also as a general learning experience.... code written by Carl and 
study it.


its very had to read, cause Carl optimised the word count so its 
ridiculously compact.. but there are a lot of little coding gems 
in some of the patterns he uses.  and it helps a lot to understand 
some of the ideas behind many functions which might look obscure 
or rarely used.
Davide:
15-Jan-2010
I personally prefer when a function accepts none value and doesn't 
stop with an error but returns none.

The code is more compact and I can write error handler only If I 
really need it.
Steeve:
16-Jan-2010
Not enough though. 

I complain too often that basic functions are sending too many errors 
instead of returning a default value (none is a good one). 
Which would allow a more compact code as you guys noticed.
Henrik:
16-Jan-2010
errors are a good thing. forces you to tighten up your code.
ChristianE:
20-Jan-2010
Everytime I'm writing (slow, but short) code like 

	>> unique append series 'value

or (very fast, but wordy)
 
	>> any [find series value insert series value]
	>> unless find changes 'weight [insert changes 'weight]


I'm wondering whether there's a nicer way to insert a value into 
a series only if it isn't in there yet. Something in the same line 
as ALTER.

This just reeks like the perfect situation for some Guru O'Brian 
or Gabriele D'Enciclopedia to point out that there's already a REBOL 
native which provides exactly that functionality ;-)


On a unrelated side note, I'm wondering if ALTER is missing an /ONLY 
refinement, too:

	>> alter series: [] [1 2] series
	== [1 2]
	>> alter/only series: [] [1 2] series
	** Script Error: alter has no refinement called only
	** Near: alter/only series: [] [1 2] series


Would that be worth adding to R3, I'm thinking about ticketing it 
as a wish in CureCode?
Maxim:
20-Jan-2010
I've written such a function often.  its much more usefull than ALTER 
in my use... I'
ChristianE:
20-Jan-2010
I guess additional refinements to a function as fundamental as INSERT 
are a no-go for performance reasons. Probably ALTER/INSERT or ALTER/ONCE 
though:

	>> alter/once [] flag
	== [flag]
	>> alter/once [flag] flag
	== [flag]


See the dance REBOL/View's FLAG-FACE is doing to achieve something 
like that (and a little bit more):

	flag-face: func [
	    "Sets a flag in a VID face."
	    face [object!]
	    'flag
	][
	    if none? face/flags [face/flags: copy [flags]]

     if not find face/flags 'flags [face/flags: copy face/flags insert 
     face/flags 'flags]
	    append face/flags flag
	]
Steeve:
20-Jan-2010
Agree, ALTER is definitivly useless.

Not the first time someone is asking to change ALTER in a better 
usefull behavior.
Maxim:
20-Jan-2010
Carl uses ALTER in a few scenarios, for as a toggle mechanism.
ChristianE:
20-Jan-2010
Yes, from a logical perspective ALTER behaves like XOR, where often 
one only really needs an equivalent of OR.
Maxim:
20-Jan-2010
I'd call the function include... and it could work on strings too, 
doing a find
ChristianE:
20-Jan-2010
INCLUDE in R3 is not a global word, in the code im currently writing

	>> include package/changes 'weight


reads very nice. Sadly, it's signature wouldn't be compatible with 
EXCLUDE, which only allows series and sets as it's second argument. 

The two refinements /INCLUDE and /EXCLUDE though would make ALTER 
more usefull.
Steeve:
20-Jan-2010
I am more in favor of finding a short name, it's a very common idiom.
ChristianE:
20-Jan-2010
Yeah, it is a common idiom. But some symmetry to REMOVE FIND FLAGS 
FLAG would be nice, and I don't expect Carl or anyone to be willing 
to replace REMOVE FIND by another native or mezzanine. That wouldn't 
be worth it.

For now, I've decided to go with 

	>> union package/changes [weight]
	>> exclude package/changes [address]

since speed is really nothing to worry about in my case now.
Gregg:
21-Jan-2010
I thought ALTER was going to go away in R3, because nobody uses it. 


As an example of a func that operates conditionally, it's nice, but 
I can't remember ever *needing* it.
Gregg:
21-Jan-2010
I would still like to set up metrics to see what funcs are used most, 
for both development and production (i.e. profiling), and set up 
a rating system. There have been some ad hoc analyzers in the past, 
but no reference system.

Yes, Graham, I know. I should just do it. :-)
Henrik:
21-Jan-2010
Carl posted a bug in curecode today, so I guess he's back to R3 coding.
Janko:
21-Jan-2010
---

ok.. moving here from !REBOL3 talking about a sandoxed execution 
option and option to somehow separate native Rebol pure and unpure 
functions
Graham:
21-Jan-2010
or create a safe dialect that looks like rebol ...
Janko:
21-Jan-2010
I will give another example where I claim doing a dialect for it 
all is useless option. So you have a rebol server that holds a big 
block of users in ram you send it 2 functions a filter >> function 
[ U ] [ all [ greater? U/age 20 lesser U/age 30 equal? U/gender 'female 
] << and a mapping function >> function [ U ] [ uppercase rejoin 
[ U/name " " U/surname ] ] << server will accept the code and collect 
items where first returns true then process them vith mapping function 
join them with reducing >> function [ U ACC ] [ rejoin [ ACC ", " 
U ]<<  function and return the result.
Janko:
21-Jan-2010
Graham: I don't know what you meant with that scentence. If I came 
out as arrogant or attacking you in my writing above, I can say I 
*really* didn't mean it. I am just trying to get my message accross, 
which I am not so good at since english is not my native lang, it's 
1:25 in the night here and I am a little nerwous since I told someone 
I will finish something before tomorrow and I am chatting here instead 
of doing it :)
Graham:
21-Jan-2010
I'm saying that if you create a safe dialect that people can use 
for sending functions across the network in r2 .. well, great ... 
we can all use it.
Janko:
21-Jan-2010
aha, but wouldn't that be recreating rebol in rebol. and chance is 
that that rebol will behave a little different than normal rebol 
in some edge cases
BrianH:
21-Jan-2010
Well, in R3 we don't have pointers or pointer arithmetic, you can't 
just reference arbitrary memory, all data has to be either literal 
or returned from a function. Words aren't bound by default, they 
are bound by the LOAD and DO mezzanine code, which can easily be 
replaced for your sandboxed code. The code can run in an isolated 
module with careful control of its imports.
Graham:
21-Jan-2010
There's a web demo of R3 ... .
BrianH:
21-Jan-2010
A sandboxed dialect in R2 would be slower because of the overloaded 
ordinals.
Janko:
21-Jan-2010
Maybe something related .. why google is using Lua : 

http://google-opensource.blogspot.com/2010/01/love-for-luajit.html
http://article.gmane.org/gmane.comp.lang.lua.general/62321

>>Our Lua usage isn't too widespread at the moment; it's really one
infrastructure project in particular that uses Lua to allow

user-defined functions to run within a tightly controlled container.

Lua was the best choice, because of its low overhead, fast execution,
and the ability to set limits on execution time.<<
BrianH:
21-Jan-2010
Lua was designed as an extension language, not a general-purpose 
language.
Janko:
21-Jan-2010
the fact that R3 will be embeddable inside c apps is a HUGE plus 
in my view too
BrianH:
21-Jan-2010
They make it stronger at a different field of endeavor. We can borrow 
ideas from Lua for those occasions where we are performing Lua-like 
tasks, especially to make extension language dialects.
BrianH:
21-Jan-2010
And these embedded dialects could even resemble a subset of the DO 
dialect.
Janko:
21-Jan-2010
BrianH: while I have you here :)) .. is there any chance to have 
a curry word in rebol 


>> format-money "$" 10000 "" "," "." ; args are: before number after 
1000-separator dec-separator
>> format-money "$" 4500 "" "," "." 

>> my-format: curry format-money [ "$" _ "" "," "." ]
>> my-format 10000
>> my-format 4500
BrianH:
21-Jan-2010
Try using APPLY in a generated wrapper function.
BrianH:
21-Jan-2010
It will be a little tricky if you want to support get-word and lit-word 
parameters. It might be at the same scale as APPLY in R2. See the 
source of APPLY for details.
BrianH:
21-Jan-2010
In any case it would be a *lot* slower than making wrapper functions.
Janko:
21-Jan-2010
aha, then it's maybe not that usefull.. I have wrapper function right 
now for this case... basically I have a closure money-format-maker
BrianH:
21-Jan-2010
Take a look at the new functions in 2.7.7, particularly APPLY and 
CLOSURE.
BrianH:
21-Jan-2010
REBOL doesn't use a stack machine. IT was a proposal for a function 
to return the result of the conditional expression of the nearest 
enclosing conditional function, basically IF or UNLESS. If we can 
add CASE support too that would be amazing, but it's unlikely without 
IF being native. As it is a mezzanine IF function would need debug 
privileges.
BrianH:
21-Jan-2010
a mezzanine IF function -> a mezzanine IT function
Davide:
21-Jan-2010
What about a "pipe" operator (as in F#), such that you can write 
something like:
read/lines %files | remove-each x [10 > length? x] | sort 

Would be simplier to read than:
sort remove-each x read %file [10> length? x]


Basically the pipe gives the parameter to the following function 
that is of the same type of the function that precede it.
BTW I think that this could be done with a dialect
BrianH:
21-Jan-2010
To know which parameter to pass along you'd need a dialect with a 
list of supported functions in its code.
Davide:
21-Jan-2010
isn't the first parameter of remove-each a word ?
BrianH:
21-Jan-2010
There's a lot of tricks that you can do with compiled languages with 
fixed function definitions that you can't do as easily in REBOL without 
whole program analysis.
BrianH:
21-Jan-2010
It just happens that that function value is assigned to that word. 
With the next call of the piped code it might be a different function.
BrianH:
21-Jan-2010
People say "do it in a dialect" like those come for free. There's 
dialect processing overhead, issues of when the arguments are processed, 
decisions about whether there are keywords or not. To get an idea 
about the real overhead of doing it in a dialect, look at the source 
of APPLY or MAP-EACH in R2. Both are compiled dialects.
Janko:
21-Jan-2010
data: parse-fixed-width-lines read/lines %PO.txt [
	vat-incl: 4 [ trim empty? not ]
	vat-num: 9 trim
	...
]

this func is used to execute [ trim empty? not ] with a value.. which 
is similar to pipe or stack lang with only 1 level deep stack :)) 

stream-through: func [ fs d /local x acc ] [ accumulate x acc copy 
[] fs [ do compose [ (x) d ] ] ]
Gregg:
23-Jan-2010
Janko, Ladislav did the most extensive CURRY I know of, though Joel 
Neely also did one, and a number of us have rolled simple versions 
here and there. 

http://www.fm.tul.cz/~ladislav/rebol/curry.r
Henrik:
23-Jan-2010
Is there any solid way to find which chars are illegal in a specific 
file system?
Terry:
23-Jan-2010
I'm getting a "REST method is not defined" response.
Maxim:
23-Jan-2010
not an expert on REST interfaces... though I am using one with a 
server right now...
Maxim:
24-Jan-2010
like I said it depends on the server but most servers expect a form-like 
post data.
Maxim:
24-Jan-2010
name is the argument name, like you would specify in a form.
Maxim:
24-Jan-2010
(or a url, if it where a get)
Maxim:
24-Jan-2010
so you should probably have to give a name to the parameter which 
is followed by the xml data  ex:

postdata=<restmethod><sometag>value</sometag></restmethod>
Terry:
24-Jan-2010
I can try with SOAP api provided, but i get the feeling it's going 
to be just as much of a time sink.
Maxim:
24-Jan-2010
is this a pubic site?
Maxim:
24-Jan-2010
(but you need a paying account for it to be any usefull, cause its 
bound to the account number)
Maxim:
24-Jan-2010
do you have a client that works inside a browser?
Terry:
24-Jan-2010
(send you a pm)
Terry:
24-Jan-2010
(send you a pm)
Maxim:
24-Jan-2010
-you open a tcp listen port
-edit the hosts file so your remote server points to 127.0.0.1

-and then just print out the data which the client would have sent 
to the server.


this works for just about every networked application I have tried 
and is a very powerfull way to learn how to build custom clients 
in rebol
Henrik:
24-Jan-2010
Graham, this is a replacement for Gabriele's version. This one is 
more complete.
Maxim:
24-Jan-2010
I've done my own, and its similar, in size and functionality... not 
much to do... the scientific notation is a pain to manage.
Steeve:
24-Jan-2010
well, using a "mask" approach, allows more capabilities then just 
providing the number of decimals.

Like I've done here for R3: http://www.rebol.net/cgi-bin/r3blog.r?view=0302#comments
(see fnum)


It's true, it doesn't handle scientific notation as entry currently, 
but hey !, it should not take more than 2 or 3 more lines.
Henrik:
24-Jan-2010
Yes, agree. I'm helping building a rather large app, where this is 
important and when things like this aren't trivial to solve... But 
what ever happens, I think we need a function like this in R3 and 
R2-Forward.
Gregg:
24-Jan-2010
It should be part of a general FORMAT func IMO.
Gregg:
24-Jan-2010
It's just chocies. Format, as it stands, isn't something I'll use. 
And if someone shows me a case where the overhead has a noticable 
and visible impact on their code, I will refactor a custom version 
for them. :-) 


I'm open to discussion, scenarios, and the backs of envelopes. Where 
is FORMAT likely to be used, how often will it be called, and how 
slow is too slow?
BrianH:
24-Jan-2010
Numeric formatting should be fast enough to get called in a tight 
loop for grid output. Thousands of times, really quickly.
Gregg:
24-Jan-2010
I have a large, non-optimzed FORMAT function, but couldn't remember 
profiling it. I just did a few quick tests.

>> time-it/count [format d "yyyy-mmm-dd"] 1000
== 0:00:00.094
>> time-it/count [format d 'rel-time] 1000
== 0:00:00.078
>> time-it/count [format 1000.01 'general] 1000
== 0:00:00.047
>> time-it/count [format 1000.01 'reb-general] 1000
== 0:00:00.031
>> time-it/count [format "Gregg" [10 right]] 1000
== 0:00:00.031
>> time-it/count [format "Gregg" [10 right #"."]] 1000
== 0:00:00.016
>> time-it/count [format true 'on-off] 1000
== 0:00

Are those results too slow?
BrianH:
25-Jan-2010
It will tell you evaluations and series created, which is a bit more 
cross-platform reliable than time. Don't know how fast your CPU is.
Henrik:
25-Jan-2010
seems there is a bug in it:

form-decimal -100 1
== "-.100,0"

Anyone with a fix?
Pekr:
25-Jan-2010
Some time ago, I did form-decimal function too. But I am really a 
coding lamer, so dunno, if it cover at least half the cases other 
versions do. Here it is:

form-decimal: func [num /local tmp main rest sign base][

     either found? find tmp: to-string num "E" [

              parse tmp [
                 [copy main to "." 
                  skip
                  copy rest to "E"
                  |
                  copy rest to "E"
                  (main: copy "")  
                  ]
             
                 skip
                 mark: (sign: copy/part mark 1)
                 skip
                 copy base to end
               ]


        either sign = "-" [

                tmp: copy "0."

                loop ((to-integer base) - 1) [insert tail tmp "0"]
                insert tail tmp rest
        ][
                tmp: copy ""

                insert tail tmp join main rest

                loop ((to-integer base) - (length? rest)) [insert tail tmp "0"]  
                    
                           
        ] 
     
      tmp                 

     ][num] 

]
Henrik:
25-Jan-2010
Graham, wouldn't it be more appropriate to simply never output scientific 
numbering and then create a scientific formatting function?
Janko:
25-Jan-2010
is form-decimal for scientific format for really large/small numbers 
like 1.25e+100 ? or is it for stuff like money 12.300,00 ? I have 
a function for the money :) (formating) , it's quite short if I remember 
correct.
Graham:
25-Jan-2010
That's a good point, if you only need a couple of decimal places, 
the form decimal could be much shorter
Gregg:
25-Jan-2010
SPEED? == 2'450 here.


I very much like the idea of combining heuristics with profiling. 
But if we're just going for rough estimates, we only need to know 
if a machine is extraordinarily fast or slow. Then we say "is 20K 
calls/sec acceptable in terms or order of magnitude?"
amacleod:
26-Jan-2010
Ok, I see...its a combo of string and decimal..
james_nak:
26-Jan-2010
I think I asked this before or figured it out but now the mind has 
lost the answer. I build strings (via a join) that reference existing 
objects.  Obviously the joining part is easy but of course I end 
up with a string.
Graham:
26-Jan-2010
>> to-path "a/b/c"
== a/b/c
james_nak:
26-Jan-2010
Graham, here's the issue: I have some vid objects such as ua-fname: 
field. They follow a pattern in that the "ua" stands for "User Add" 
and the rest corresponds to the actual field name in the DB. The 
function I am writing is created in a way to be very generic and 
knows how to handle an insert into the DB based on a few parameters. 
What I am looking for is a way to "create" a name by joining "ua-" 
and field name which refers to the actual vid gadget.
james_nak:
27-Jan-2010
Graham, you are the man. That works perfectly. Thanks for the info 
and saving me a ton of time.  That's one of those "How in the world 
did you know that?" things to me.  I guess that "do" says "What does 
this mean to me?" - the "me" being Rebol . I appreciate your help 
(once again).
Gregg:
27-Jan-2010
forskip+: func [
        "Like FORSKIP, but with local FIRST? and LAST? support."
        [throw catch]

        'word [word!] {Word set to each position in series and changed as 
        a result}
        skip-num [integer!] "Number of values to skip each time"
        body [block!] "Block to evaluate each time"
        /local orig result
    ][

        if not positive? skip-num [throw make error! join [script invalid-arg] 
        skip-num]
        if not any [
            series? get word
            port? get word
        ] [

            throw make error! {forskip/forall expected word argument to refer 
            to a series or port!}
        ]
        orig: get word
        use [first? last?] [
            first?: true
            last?:  false
            body: bind/copy body 'first?

            while [any [not tail? get word (set word orig false)]] [
                if tail? skip get word skip-num [last?: true]
                set/any 'result do body
                set word skip get word skip-num
                first?: false
                get/any 'result
            ]
        ]
    ]
Gregg:
27-Jan-2010
b: [a b c d e]

forskip+ b 1 [
    if first? [print 'first] 
    print b/1 
    if last? [print 'last]
]
Gregg:
27-Jan-2010
And LAST? wouldn't be like SINGLE? in the context of FORSKIP with 
a bump value other than 1.
45801 / 6460812345...457458[459] 460461...643644645646647