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

World: r3wp

[Core] Discuss core issues

Henrik
4-May-2007
[7772x2]
brock, notice this:

to-path ['write 'append]
sorry, strip the 's
Pekr
4-May-2007
[7774]
why not simply use:


either condition [write/append %test.txt "This is a text"][write 
%test.txt "This is a text"]
Anton
4-May-2007
[7775]
do pick [write write/append] condition %test.txt "This is text"
Henrik
4-May-2007
[7776x2]
do [to-path [write all [append? 'append]] %test.txt "this is a text"]
if append? is a flag, that is
Pekr
4-May-2007
[7778]
Anton - very elegant!
Anton
4-May-2007
[7779x2]
must reduce first
and even then, if the condition is false:
>> to-path reduce ['write all [false 'append]]
== write/none
Brock
4-May-2007
[7781x2]
checking out the options provided, may take a while to respond... 
thanks for the responses
Anton, that is an interesting solution indeed
Anton
4-May-2007
[7783x3]
do to-path compose [write (any [all [true 'append] ()])] %testible.txt 
"test"
I use the empty paren to generate an unset! value. Compose then dissolves 
a false condition to nothing.
Thankfully a path! with only one word ('write) in it still works 
just like a word! ('write) does.
Brock
4-May-2007
[7786]
Anton, the last options seems to auto-detect if the file is created 
and appends if it created, is that true?
Anton
4-May-2007
[7787]
Correct.
Brock
4-May-2007
[7788x3]
your first solution is more along the lines of what I need.   I need 
to be able to control whether I write or append through the condition.
Thanks for your solutions.  I'm going to play around with Pekr's 
contributions to see what he did and better understand where I went 
wrong.  Thanks guys
Pekr, regarding not simply doing this in an either statement.  I 
have this scenario in a couple of locations and wanted a be a little 
more elegant.  I know it wouldn't add alot of space, just was trying 
to be more elegant.
Anton
4-May-2007
[7791]
Hard to achieve elegance here. Different people wrote helper functions 
for this type of thing. DO PICK is good for just one refinement, 
but the second one is better for several refinements (and accompanying 
arguments).
Brock
4-May-2007
[7792x2]
Henrik, your solution is nice as well.  Pekr, I see the err in my 
ways with the to-path command.  That and enclosing the entire command 
in a block made all the difference.
Anton, yes, I am really just trying to minize my overuse of either 
yet still be readable, and memorable for future use.
Anton
4-May-2007
[7794]
http://anton.wildit.net.au/rebol/doc/flag-val-doc.txt
Henrik
4-May-2007
[7795]
This is one of my pet peeves, that optionally using refinements can't 
be simpler than this.
Anton
4-May-2007
[7796]
I think it was decided some function will be built into R3 which 
makes refinement and argument propagation easier.
Gabriele
4-May-2007
[7797]
and that would be APPLY
Henrik
6-May-2007
[7798]
A question: Does anyone know the ratio of mezzanine vs. native functions 
in a standard REBOL/View 1.3.2? I'm trying to use that as a statistical 
argument of how much of REBOL 2 is currently open source. :-)
Sunanda
6-May-2007
[7799]
These two lines get you close to a answer
  help function!
  help native!

May also need to count various things in the system object as available 
source (not quite *open* source)
btiffin
6-May-2007
[7800]
Hi,  I've been pondering electrical circuits.  Should NOT none return 
none?

low voltage NOT should be high, high voltage NOT should go low, but 
a zero voltage NOT should be no volts? No?
Sunanda
6-May-2007
[7801]
REBOL has slightly wonky three-value logic:
(not none) = (not false)
== true
>> none = false
== false
btiffin
6-May-2007
[7802]
Yeah, I was looking at that.  The output wire I have on a NOT circuit 
is always lit.  I
have to test for "no input" along with the 1's and 0's.  :)
Gregg
6-May-2007
[7803]
I would say a zero voltage is zero volts which, in that domain, might 
be called a lack of voltage, or no voltage. i.e. a REBOL none value 
is not the same as no voltage, but you might have a NONE? func in 
that domain that means "zero? volts".
btiffin
6-May-2007
[7804]
I'm coding an interactive half-adder circuit today.  The NOT gate 
outputs are lit even

if the "circuit" doesn't have any virtual power running through it. 
 Easy to work round

but this was more of a theoretical.  :)  In real life, a NOT gate 
doesn't go high for
no-volts, only low-volts no?  I don't know enough.  :)
Anton
7-May-2007
[7805x5]
Henrik:
result: [] 
foreach word first system/words [
	if value? in system/words word [
		type: type?/word get in system/words word 
		either blk: select result type [
			append blk word
		][
			repend result [type reduce [word]]
		]
	]
]

print ["actions:" length? result/action! "natives:" length? result/native! 
"funcs:" length? result/function!]
actions: 120 natives: 137 funcs: 238
(and don't forget op!)
Brian, Gregg, in electronics, which of high and low voltage is considered 
"true" and "false" can be different in each circuit.
Henrik
7-May-2007
[7810x2]
anton, interesting, thanks
does RENAME not support renaming dirs?
Pekr
7-May-2007
[7812]
RENAME - new name for Rebol :-) Rename your toolset :-)
Maxim
7-May-2007
[7813x2]
I would have thought someone would have suggested 
Do
cause you just want to DO stuff.
btiffin
7-May-2007
[7815]
Terminology question.  For proper REBOL terms, now is a native!  
But is it a misnomer

to say function?  The question came up as I'm trying to describe 
now/time.  Can I

say function, or is it more properly the verbose "time refinement 
of the now native"?
Sunanda
7-May-2007
[7816]
RT seem happy the word function in both cases:
http://www.rebol.com/docs/dictionary.html
Perhaps we have to distniguish two types: native and mezzanine.
btiffin
7-May-2007
[7817x2]
I'm aiming a lot of the Usage docs at beginners, but I don't won't 
to pollute the purity
of the terminology too soon in their careers.  ;)
In this case, (I'm doc'ing the timer and timing related scripts) 
I think I'll go verbose.
BrianH
7-May-2007
[7819x2]
As long as you don't elaborate on the differences between natives, 
actions and ops on every reference to functions of any of those types, 
then it is cool to use the term "native" to refer to all of those. 
The only things that matter about the difference between native and 
REBOL functions are the speed of natives and the available source 
code of REBOL functions.
IMHO
btiffin
7-May-2007
[7821]
Thanks for the opinion Brian.  Noted.