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

World: r3wp

[Core] Discuss core issues

Steeve
8-Jan-2010
[15422]
Terry, i don't think your output must be
{
\'hello\'s {Worlds \';

...and prints...

 'and {so "on';
}

And yet, that's what you show us actually
Gregg
8-Jan-2010
[15423x2]
build: func [
    {Return text replacing $tags with their evaluated results.}
    content [string! file! url!]
    /quiet "Do not show errors in the output."
    /local out eval value
][
    content: either string? content [copy content] [read content]
    out: make string! 126
    eval: func [val /local tmp] [
        either error? set/any 'tmp try [do val] [
            if not quiet [
                tmp: disarm :tmp
                append out reform ["***ERROR" tmp/id "in:" val]
            ]
        ] [
            if not unset? get/any 'tmp [append out :tmp]
        ]
    ]
    parse/all content [
        any [
            end break

            | " $" [copy value to " " | copy value to end] (eval value)
            | copy value [to " $" | to end] (append out value)
        ]
    ]
    out
]
Now, that's norribly naive, and doesn't work because of that. e.g. 
it needs a space before the $ marker, so a var at the beginning of 
the text gets missed.
Steeve
8-Jan-2010
[15425]
yes seems a little messy Greg ;-)
Gregg
8-Jan-2010
[15426]
Well, what do you in five minutes? ;-)
Terry
8-Jan-2010
[15427]
Spend 6 :)
Gregg
8-Jan-2010
[15428x2]
Needs a different name too, as Ladislav has a nice BUILD func that 
works on blocks.
I need a spec first. ;-)
Terry
8-Jan-2010
[15430x3]
Although, i would be impressed if it didn't choke while trying to 
escape stuff.
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.
via AJAX
Steeve
8-Jan-2010
[15433]
I say it again, you didn't give us the real output. Doing some assumptions, 
i got this.

varA: { \'hello\'s ^{Worlds \';}
varB: {
 'and ^{so "on';
}

print rejoin  [{<button onclick="alert('} varA {');">CLICK ME</button>} 
varB ]


<button onclick="alert(' \'hello\'s {Worlds \';');">CLICK ME</button>
 'and {so "on';

So where is the burden ? i don't see one
Terry
9-Jan-2010
[15434x2]
Should probably put this in rant.. but just spent the last hour wondering 
why my function wasn't working

result: sofp 'firstname'

the solution? change the single quotes to double.. aye carumba
Steeve, it's cumbersome.. I spend more time joining and escaping 
than anything else.
Henrik
9-Jan-2010
[15436x2]
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.
rephrasing that: not "easiest way", but easiest to use in the end.
Janko
9-Jan-2010
[15438]
as anyone tried to run cheyenne or rebol on sheevaplug ( http://www.globalscaletechnologies.com/t-sheevaplugdetails.aspx
)
WuJian
9-Jan-2010
[15439]
Good stufff
Henrik
13-Jan-2010
[15440]
does anyone have a rebol based bracket checking tool? preferrably 
something that can be integrated into a diagnostic tool.
Steeve
13-Jan-2010
[15441]
hey ?
WuJian
14-Jan-2010
[15442]
e
	)
BenBran
14-Jan-2010
[15443]
I have the code:
case equal? length? find myLine "text" 4 [...]
It fails on ==none
I can do it in more lines of code but was wondering the 
shortest way to get past this.
Any suggestions?
tia
Graham
14-Jan-2010
[15444]
what happens if you don't find the text ??  It gives none
BenBran
14-Jan-2010
[15445x2]
yes that is correct
I'd like to ignore if it gets 'none'
Graham
14-Jan-2010
[15447]
so you have multiple conditions but you're only checking for one
BenBran
14-Jan-2010
[15448x2]
yes have numerouse cases
numerous
Graham
14-Jan-2010
[15450x2]
I mean you have mulitiple outcomes in that code you have written 
but you're only checking for one
if mark: find myline "text" [
	... 

]
BenBran
14-Jan-2010
[15452]
I don't follow what you mean.
Graham
14-Jan-2010
[15453]
if all [
	mark: find myline "text" 
	4 = length? mark

][
	case [

	]
]
Maxim
14-Jan-2010
[15454]
the if isn't required here.
Graham
14-Jan-2010
[15455]
true
Maxim
14-Jan-2010
[15456]
this is exactly the same:

all [
	mark: find myline "text" 
	4 = length? mark

	case [

	]
]
Graham
14-Jan-2010
[15457]
all [
	mark: find myline "text"
	4 = length? mark
	case [

	]

]
Maxim
14-Jan-2010
[15458]
hehe
Graham
14-Jan-2010
[15459]
snap
BenBran
14-Jan-2010
[15460]
the power of rebol will never cease to amaze me.
Maxim
14-Jan-2010
[15461]
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
[15462]
case [
	not mark: find myline "text" [none]
	4 <> length? mark [none]
	...

]
Graham
15-Jan-2010
[15463]
not so easily read  ;)
Steeve
15-Jan-2010
[15464x6]
don't think so, matter of habit
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
	...

]
*combination
and most of the time, it's the fastest way of doing tests
ALL is slow
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
[15470x2]
other languages promote it based on the general suckyness of the 
case statement in most languages.
which act more like switch than rebol`s case