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

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

RobertS
5-Aug-2007
[740x4]
I meant that I don't much ask ''But is that Oz?" the way we ask "but 
is that "Rebol?" or "But would that be Rebol?"  It comes from my 
aversion to the questions/attacks of  purists who insisted that Turbo 
Prolog was not really a PROLOG.  Neither is what Prolog became (Prologia 
IV)

The Slate team for Smalltalk3 ( if you think of JavaScript as Smalltalk2 
 [heresy] ) now have Self and Strongtalk to look over with 15+ years 
of hindsight.
It appears to have slowed them down a lot.

I can't wait to get my hands on that Rebol3 beta ...

PS  if you don't think JavaScript was Smalltalk2, just look at Io, 
the language ;-)

PPS  the author of CTM was probably asking himself "But will they 
see that this is not Oz? " with every chapter (Peter Van Roy,  'Concepts, 
Techniques and Models of CP', MIT Press) - the O-O chapter is arguably 
the worst flaw in a fine MIT intro book - unless it is the flaw of 
totally ignoring JavaScript as a functional prototype-based lang. 
( and I don't recall mention of Curl or Rebol )

Another language evolving: Cecil into Diesel
ah, c'mon
	mold/all reduce [ does [ join "Rebol" "3"]]
is cute ...

 ( as I wait to be reduced to a puddle one atom thick for failing 
 to fit the mold )
I'll keep my posts, well, shorter.  Promise. sorta
it's my 'Liquid Rebol' joke; it belongs in chat.  New people always 
post in the wrong threads.  Better "I'm new" than "They're new" or 
"We're new"
	joke = new Rebol(2)  // javascript

 funnier: make classInstance! RebolObject [prototype! classObject! 
 object! ]
;; this is neat

 mold make object! ["test"]   ;; warning: to preserve a spec block 
 be sure to use    obj: make object! copy/deep specBlk

;; copy/deep issues are rampant in Smalltalk ( if you get the impression 
that I think Smalltalkers neglect Rebol, yer rite )
Geomol
5-Aug-2007
[744]
In relation to Roberts post:

>> load mold reduce [ does [ join "Rebol" "3"]]
== [func [] [join "Rebol" "3"]]
>> load mold/all reduce [ does [ join "Rebol" "3"]]
** Syntax Error: Invalid construct -- #[
** Near: (line 1) [#[function! [][join "Rebol" "3"]]]

What!? :-)
Gabriele
5-Aug-2007
[745]
geomol, that's a bug. i think it's in rambo too.
RobertS
5-Aug-2007
[746x4]
load mold/all reduce [does [join [ Rebol" "3" ]] ;; thanks. In STSC 
APL we could use 'load' or 'laod' ...
laod: :load  ;; Rebol3 is free of wordspace worry size anxiety
;; my Rebol tutorial would include something on quotes , such as
	>>'test'
	== test'
	>>mold 'test'
	== "test''"

 >>mold join 'test' "tested"  ; note use of {} to avoid double double-quotes
	>> ""test""  ;; error - but which error and why?

 >> "'test''"  ;; be-aware that PDF files may use left-single-quote, 
 right-single-quote, left-double-quote  and single-quote != apostrophe 
 != backtick ...
;; and definitely something to include 
	>> help rejoin
	>> source rejoin

( I am now talking with a publisher. Hurray!  The hard part is behind 
me!   Now to have some fun ...   Dead-line?  What dead-line was that? 
 When!?  )
>>system/console/prompt: [ reform [ now/time ">> "]]  ;; good tutorial 
candidate from 'Rebol for Dummies' by Ralph Roberts
>>to-integer #2A  ;; Hex. But what was the question?

>>big-Q: does [ rejoin [ none ". But the answer is: " to integer! 
#2A]]
>>big-Q

>>little-Q: [ rejoin [ none ". But the answer is: " to integer! #2A]]
>> do little-Q

>> do big-Q ;; now you get an error because none is the has-no-value 
word
>> type? none 
>> path? 'none/first
;; 24Arghhh!{]}['   there was a typo 2 posts back ... cannot go back 
4 2 posts ...
;;

load mold/all reduce [does [join [ "Rebol" "3" ]]] ;;  typo. Arggh!!! 
 in code ending:  " thanks.  In STSC APL blah-blah "
laod: :load
laod mold/all reduce [does [rejoin [ Rebol" "3" ]]] ;; better
laod mold/all reduce does [join [ Rebol" "3" ]]  ;; huh?
mold/all reduce does [join [ Rebol" "3" ]]  ;; oh ...

comment {
	[func [][rejoin ["Rebol" 3]]]
versus
	{#[function! [][rejoin ["Rebol" "3"]]]}
}
pg 329 ff of the old 'Official Guide' book is a treatment of 
	reduce [none]

that is so very fine, I suppose, because so well-motivated by its 
context.


>> type? first reduce [none]    ;; compare this to:   type? first 
[none]

>> type? first reduce [yes]	;; compare this to:   type? first [yes]
RobertS
25-Aug-2007
[750]
set  get 
this might not be obvious if you are new ( like me )
beBoundToWord: 'aWord
set :beBoundToWord 42
print aWord 
get :beBoundToWord
word? :beBoundToWord
Henrik
25-Aug-2007
[751]
you mean the last line?
RobertS
25-Aug-2007
[752]
; this also not so obvious  about index versus path
  blk: [ t' t'' t''' ]
  blk/t'
  blk/1
  blk/t': 42
  blk
  set blk/1 21
  blk
  blk/1
  :blk/1
  get blk/1
blk2:  [ a' b' c' ]  
  set blk2/a' 42
  blk2
  blk2/2
  blk2/a'
  get blk2/a'
Henrik
25-Aug-2007
[753x2]
actually what you are finding confusing, I think, is a simple rule 
that paths point to the next element in the block, where index does 
not.
so it works like it should :-) but this is the rule. this way you 
can quickly access words in a block through a path.
RobertS
25-Aug-2007
[755x4]
; one thing I failed to note with the  set  and  get 
>> aWord
** Script Error: aWord has no value
** Near: aWord
>> 'aWord
== aWord
>> aWord
** Script Error: aWord has no value
** Near: aWord
>> word? aWord
** Script Error: aWord has no value
** Near: word? aWord
>> word? 'aWord
== true
>> a: 'aWord
== aWord
>> aWord
** Script Error: aWord has no value
** Near: aWord
>> word? :a
== true
>> :aWord
** Script Error: aWord has no value
** Near: :aWord
>> :a
== aWord

; this seems worth getting clear:  that a word can be a value and 
still not be used until it has a value
oh, I am not confused -.. I put this for anyone who is new to explore 
-- but thanks
More and more I think that was is not obvious is no longer obvious 
once it is obvious

There is an 'active' LISP tutorial that would be a good model for 
a 'Rebol for newbies'

I would like to use the approach taken in the 2.3 "Official Guide" 
book to introduce unit testing in Rebol for TDD "from-the-get-go"

In Smaltlalk we used to count on newbies exploring in a workspace: 
we reaped a culture where people thoght the point of O-O was to write 
subclasses and create deep hierarchies like, say, Collection.  What 
was obvious was just wrong.  Messages were the point, not classes, 
let alone sub-classing.  Am I wrong to suggest to anyone new: "buy 
as used copy of "The Official Guide" " ?  For Oz, which is so much 
like Rebol, I do not hesitate to recommend Peter Van Roy's CTM from 
MIT Press.  Scheme has 'Little Schemer' and 'Simply Scheme'   The 
latter would be my model for an interactive tutorial in which you 
LEARN.  Smalltalk was supposed to be about how we model things ( 
how we learn how things interact )

I think it fair to say that it failed.  Classes were not the point. 
 Objects were not the point.  Things went wrong early on in abandoning 
the Actor Model in early 70's     I am hoping Rebol3  is getting 
it right ;-)   ( Io, the language, is quite inspiring ( www.iolanguage.com 
) but I still think Oz is a great intro to Rebol (they, too, lack 
an effective learning tool to "think in Oz " )
;One tip if you are new like me
  save %hist_001.r system/console/history
; then in user.r
  system/console/history: load %hist_001.r
: when you have materials worth reviewing as you learn ....


; PS  I meant 'former' as model, i.e, "Little Schemer"  "Seasoned 
Schemer" "Reasoned Schemer"

Prolog has the 'Art of .. ' 'Craft of ' and 'Practice of Prolog' 
series
Henrik
25-Aug-2007
[759]
robert, we are building a Wiki for R3. would you be interested in 
doing smalltalk vs. prolog vs. other-languages-you-know vs. Rebol?
RobertS
25-Aug-2007
[760]
would love to
Henrik
25-Aug-2007
[761]
excellent. I will try to make arrangements.
btiffin
25-Aug-2007
[762]
Robert;  I struggled trying to explain 'word'  in the new Glossary. 
 Yes, it needs to be well documented for those of us that can't tie 
our REBOL shoelaces with one-hand yet.  Once you can tie shoelaces 
it's almost impossible to forget how, but until then the obvious 
is obviously non-obvious.
Gabriele
25-Aug-2007
[763]
messages: agreed, that's the interesting part. too bad the C++ and 
Java guys have no idea :) I think that rebol/services could cover 
that part well. you can even compare that to an erlang-style collection 
of nodes communicating thru messages.
RobertS
25-Aug-2007
[764]
It is nice to see Joe Armstrong's 'Erlang' book in print with Pragmatic. 
 Does someone here know Dave Thomas at Prag Prog I wonder?
RobertS
26-Aug-2007
[765x3]
Can u tell me why we use datetype  unset!  in the func  list-dir 
 but not in the func  to-logic 
I.e.  why do we not have
   to logic!
return false when I pass in it an unset!
?

Or am I missing something here ?  Maybe I miss what is the diff between 
 'qwetr  being type set-word! and it not having a binding yet or 
my having sent
    unset 'qwetr

Is this like the  diff in other lang's between  nil_or_null and undefined_or_undeclared 
?
oh I see

   listdir   ; the param is not there, i.e., we have something unset!

    listdir qwetr  ; errror


But could the latter not return false a la negation-as-failure meaning 
I cannot browse your putative directory ?


I guess I am asking " What is the Rebolesque way of seeing this? 
"
Say i have
   a: [ 1 b 2 ]

now 
   list-dir to-url a/2

a/2  ; b

; I see this as different from
   list-dir this-word_occurs _nowhere_in_this_context
   list-dir  this-word-has-no-binding-yet-in-this-context

to-logic a/2   ; this would be false
to-logic  a/qwetr   ; i don't know what to think
to-logic  qwetr    ; my question ( I thought ? )
Ladislav
26-Aug-2007
[768x4]
hello RobertS, to-logic does not accept unset! value. Functions that 
accept uset! look as follows: my-func-accepting-unset: func [arg 
[any-type!]] [...] or func [arg [unset! ...]] [...], functions having 
the following spec: func [arg] [...] generally accept neither unset! 
nor error!
so, if I wanted to patch to-logic I could write e.g.: 

    to-logic: func [value [any-type!]] [
        case [
            ; taking care of #[unset!]
            not value? 'value [false]
            error? :value [true]
            true [to logic! :value]
        ]
    ]
HTH
(you can change the above definition to suit your needs)
RobertS
26-Aug-2007
[772]
thanx
btiffin
26-Aug-2007
[773]
Robert;  By definition in REBOL the only logical false values are 
#[false] and #[none]  So for instance, integer! 0 is logcally true, 
which took me by surprise at first, but that is the way of REBOL. 
 Surprise! Usually pleasant. :)


Aside: The other words that evaluate as false; no, off (others?) 
do not have a pure lexical form so, #[off] is not a loadable value 
but the word off still evaluates to #[false].


And  to logic! get/any 'an-unset-word  will evaluate as #[true], 
as back to the defintion, only #[false] and #[none] are false.  As 
far as I understand it anyway.
Graham
27-Aug-2007
[774]
annoying .. can't use those forth tricks that require 0 to be false!
btiffin
27-Aug-2007
[775]
It is kinda  Born and raised with 0 false 1 true (actually being 
a polyFORTH coder) 0 false 1 true -1 really true.  The whole all 
bits on argument.  :)
RobertS
27-Aug-2007
[776]
I have written an alternate form of the func WHAT  that dumps to 
a file ( I have only 481 global functions at startup )

I will try to find time to build a page that gives clicks for SOURCE 
and HELP for each func in a given file dump (and maybe group them)
I tried messing with PRINT but that broke HELP and SOURCE ;-)
Gabriele
28-Aug-2007
[777]
you can also just:   echo %somefile.txt    - everything that is printed 
also goes to the file. echo none disables it.
RobertS
29-Aug-2007
[778]
Thanks.  btw
I saw this on MAP on the Rebol3 group
>> map [where:] [1 2 3 4 5 6] [take/part where 2]

== [[1 2] [3 4] [5 6]]          ; Graham said not too intuitive - 
I prefer the solution you suggested to me a few days back

; Will we have FOLD in Rebol3?  If so, it should be intuitive, as 
should any MAP  imho   TAKE inside a MAP is counter-intuituve to 
me cuz MAP should not ;be slice-n-dice ... PARTITION/pairs   PARTITION/triples 
    partition/4   etc
Gabriele
30-Aug-2007
[779x4]
i don't think one would use TAKE often with MAP or FOREACH.
usually you just do something like map [a b] [1 2 3 4] [a + b]
a simple fold is:
fold: func [

 "Applies F to the accumulator value and, successively, each value 
 in the block."
	block [any-block!] "Block of values"
	accum "Accumulator value" 
	f [any-function!] "Function to apply"
][
    foreach val block [accum: f :accum :val]
]
RobertS
30-Aug-2007
[783x2]
; Just FYI ...

Ladislav Mecir has an excellent page on  bind   at http://www.fm.tul.cz/~ladislav/rebol/contexts.html
But it does not warn you not to try
    >> someWord: make word! ":test:"
    >> print bind? 'someWord   ; BAD IDEA
I am fine with
   >> none? bind? 'someWord
or
   >> equal? bind? 'someWord bind? 'someContext

Printing the global context seems like a bad idea, at least when 
my PC is carrying a heavy load ;-)
>> length? mold bind? 'rebol
== 504310487
Gabriele
31-Aug-2007
[785x2]
that's just like   print system/words :-)   since system/words contains 
system too, you are printing all of rebol.
the size of that depends on what you've done in the session. if you 
started the view desktop for example, you're going to get quite a 
big result ;)
RobertS
31-Aug-2007
[787]
on another topic (how like me :-)
>> source does
; leads naturally to
>> source throw-on-error
; which is a good read ... for me, anyway
Gabriele
31-Aug-2007
[788]
which should lead to investigate what the [catch] function attribute 
does :-)
RobertS
31-Aug-2007
[789]
; tutorials  on series and find/part

; I may be alone in thinking that without experimenting, a newbie 
will miss this ...  here is my experiment

; the docs say part will accept a 'range' but give no clear indication 
what a 'range' is in 2.x
text: {
    Tested this before.
    Then test these.
}

start: find text "this"
end: find start newline
item: find/part start "this" end
print item

index? find text "this"
index? start
length? start
index? end
length? end
head start
head end
index? item
head item

; by now you get that Ah-Hah experience or Eureka! or 'hot-damn!' 
as the case may be ...