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

World: r3wp

[Core] Discuss core issues

BrianW
29-May-2005
[1142]
I'm losing my mind here ... my Linux rebol scripts just aren't working 
unless I invoke rebol directly myself.
Robert
29-May-2005
[1143]
debugging: IIRC I once asked this question already but can't remember 
the answer. Is it possible from inside a function to get the set-word 
this code is bound to? I would like to be able to print the set-word 
for debugging call-traces.
ChristianE
29-May-2005
[1144x9]
See the following mailing thread:
http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlGCNJ
You may use a redefined FUNC like
func: func [
    "Defines a user function with given spec and body."
    [catch]

    spec [block!] {Help string (opt) followed by arg words (and opt type 
    and string)}
    body [block!] "The body block of the function"
/name
    word [word!]
][
    either name [
        use [self] [
            self: word 
            throw-on-error [make function! spec bind body 'self]
        ]
    ][
        throw-on-error [make function! spec body]
    ]
]
>> a: b: c: func/name [x] [either none? x [print [self "called with 
X arg of value NONE"]][probe x]] 'my-func
>> a 0
0
== 0
>> a none
my-func called with X arg of value NONE
Might cause serious binding problems, though (I haven't tested it 
in any serious means). And it may probably not suit your needs exactly.
Thought about it twice. Doesn't make any sense, anyway: it has no 
benefits over printing "MYFUNC called with ..." directly.
Ammon
29-May-2005
[1153x2]
Yeah, that's going to have some binding issues.
But you have the right idea
Robert
29-May-2005
[1155]
Ok, than we should add better trace functionallity to Rebol :-))
Anton
30-May-2005
[1156]
I agree with Allen, but I would expect FOR to be able to handle variables, 
eg:
	for i [1 to 5][
		for j [i * 2 to i * 3 step 2][...]
	]
Ammon
31-May-2005
[1157]
What's the trick to getting the @ symbol into your username when 
checking POP mail in REBOL?
PeterWood
31-May-2005
[1158x2]
If you check the ML topic index  for pop, you'll find 


http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlFSJQ

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlQGBQ

http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlQGBQ

Each of which contains the answer.
Which is :


 open [ scheme: 'pop user: "[[username-:-coxinet]]" pass: "password" host: 
 "pop.coxmail.com" ]
Ammon
31-May-2005
[1160x2]
Yup, found an email you sent to the mailing list  referencing this 
just before you posted here... ;~>
So you answered my question before I asked it.  That's pretty good. 
;~>
Allen
31-May-2005
[1162]
I'm curios as to why do people use @ in a username.? I thought the 
rfc said not to.
Ammon
31-May-2005
[1163]
In this case, ask Google why...
Graham
31-May-2005
[1164]
It's often because the ISP passes the user onto another pop server 
ie. the first proxies for the final pop server
DideC
1-Jun-2005
[1165]
Tiscali has bought many Provider in France. They handle email in 
@tiscali.fr, @freesbee.fr, infonie.fr ... with the same POP server 
(proxy?). So they need the full email as login.
Dockimbel
1-Jun-2005
[1166]
Does anyone know if REBOL runs on Windows CE.NET 4.2 ? I'd need to 
use REBOL on that platform but I don't have access to a CE.NET terminal 
and can't use an emulator because there's no REBOL WinCE x86 binary.
ChristianE
1-Jun-2005
[1167]
This probably is a silly question, but ... What is the benefit of 
DO GET IN OBJECT WORD over just writing OBJECT/WORD ? 

I see this a lot in VIEW source (e.g. in DO-FACE) and related guru 
sources. I really don't see the point of doing so, be there *must* 
be a reason. Anyone willing to educate me? Is this a path evaluation 
issue?
JaimeVargas
1-Jun-2005
[1168]
Maybe the word is dynamic?
ChristianE
1-Jun-2005
[1169]
Oh, sorry, typo here: should have read DO GET IN OBJECT 'WORD - it's 
LIT-WORD!, actually.

Of course, there *are* differences, e.g. OBJECT/WORD doesn't throw 
an error if WORD is unset. But I'm uncertain on the exact reason 
why that idiom is used.
JaimeVargas
1-Jun-2005
[1170]
Dynamic dispatch of code, if the slot exist.
ChristianE
1-Jun-2005
[1171]
Still don't get it. Both 


 do-face: func [face value][do get in face 'action face either value 
 [value] [face/data]]

 do-face: func [face value][face/action face either value [value] 
 [face/data]]

seem to work.
JaimeVargas
1-Jun-2005
[1172x3]
o1: context [
    init: [print "Init code for o1"]
    eval: [print "Eval code for o1"]
    end: [print "End code for o1"]
]

o2: context [
    init: [print "Init code for o2"]
    eval: [print "Eval code for o2"]
]

eval-obj: func [obj][
    do get in obj 'init
    do get in obj 'eval
    do get in obj 'end
]

eval-obj o1
eval-obj o2
In your example the face may not have an action slot.
Therefor throwing an error instead of graceful fail.
ChristianE
1-Jun-2005
[1175x2]
Oh, thanks, now it's all clear. I tried with setting WORD to any 
value I could image, but not with object without WORD. As always, 
so simple, so obvious! Thanks again.
Kind of obvious after someone makes it obvious to me, though ;-)
JaimeVargas
1-Jun-2005
[1177]
That seems to be the norm with Rebol. But we are so trained to look 
for complex explanations that we skip the path of less surprise.
BrianH
1-Jun-2005
[1178]
Plus, the behavior of object/word depends upon what datatype the 
word is set to and (for some datatypes) which version of REBOL you 
are running. If WORD is set to a block, OBJECT/WORD is the same as 
GET IN OBJECT 'WORD, while if WORD is set to a function, or sometimes 
a path or paren, it means DO GET IN OBJECT 'WORD. By spelling out 
what you want to do, you won't be as tied to variances in REBOL path 
evaluation and your code can be more general.
Gabriele
2-Jun-2005
[1179]
The real reason, most of the times, is what Brian says above: if 
you want to get a function value instead of evaluating it.
ChristianE
2-Jun-2005
[1180]
Yes, Gabriele, that's what I supposed it's all about, but since in 
the places I've seen it, the function weren't used as first class 
values, but rather evalutated. Jaime pointed me to another reason: 
the GET IN variant doesn't break if an object doesn't feature the 
wanted "slot". That really makes sense where code can't be too sure 
about the objects it handles.


Actually, though the guru code I mentioned was some of your changes 
to the view event- and modal system (I'm still working my way thru 
it, trying to understand it's pickier details) and other view related 
code snippets from cyphre, I'd really thought I'd better ask in core 
group, since it may come down to a more broader misconception of 
path evalutation I had. I'm happy to see that it's "only" the point 
Jamie made which I overlooked.
Gabriele
2-Jun-2005
[1181x4]
yes, the main point is that you are safer, whatever value is in the 
object. note that if the word is not available just using get in 
will break anyway in "older" versions.
>> system/version
== 1.2.8.3.1
>> obj: context [a: 1 b: 2]
>> get in obj 'c
** Script Error: get expected word argument of type: any-word
** Near: get in obj 'c
recent versions will not complain in this case (GET accepts NONE 
too)
i think in the VID case, the code is written that way so that it 
works correclty not only if face/action is a function, but also if 
it is a block (as it was in earlier versions of VID)
Guest
5-Jun-2005
[1185]
http: -> Circular forwarding is there any stable solution yet to 
avoid endless loops ? have tried to set different flaggs within the 
schemes object but can't  stop den endless loop. even read the messages-boards 
and found some hints but these doesn't work either. is there no flagg 
to set to prevend forwarding ? any hint are welcome... thanks
Gabriele
5-Jun-2005
[1186]
can you check port/locals/list? what do you get there?
Guest
5-Jun-2005
[1187]
hi gabriele, thx for reply. if I open the port, the loop instant 
apears. the only way to stop is to press escape... after this the 
port has no value.
Micha
5-Jun-2005
[1188x4]
rebol [ title: "SOCKS SERWER" ]

conn: make port! tcp://:800

proxy: make object! [ host: 208.59.117.69
                      port: 2988  ]



black-lista: [ 69.64.51.223 194.69.207.145 80.252.0.145 194.69.207.165 
217.73.17.115]




adns: open/no-wait make port! dns:///async

adns/awake: func [port /local data][                
		
		data: copy port

                print data
		
		false 
	]				

insert tail system/ports/wait-list adns





heandler: func [ port /local data dns  serwer client]

               [ serwer: first port

                          
 wait serwer
             
data: copy serwer
;data: make string! 10000
;read-io serwer data 10000
print ["data1" to-binary data]

dns: to-tuple copy/part skip to-binary  data 4 4  

insert adns dns ;print dns name



either find black-lista dns [ close serwer  print "firtled" print 
read join dns:// dns ]
                           
                            [ print "new connetion"

insert serwer  join #{005A} [debase/base  skip to-hex serwer/port-id 
4 16 to-binary dns ] 


client: make port! [ scheme: 'tcp 
                     host: system/words/proxy/host
                     port-id: system/words/proxy/port
]



;insert tail system/ports/timeout-list client

      open/no-wait/binary/async/direct client :response


client/sub-port: serwer





insert tail system/ports/wait-list  client

client/date: data

serwer/sub-port: client

serwer/awake: :request









] 



       false         
]




request: func [ port /local data  f ] 

              [ data: make string! 10000
               read-io port data 10000


if f: find data "GET /favicon.ico" [ insert port "HTTP/1.1 404 Not 
Found" 
                                      print "favicon.ico"]
 


                either (data <> {}) and not f [     print [ "data3" data  ]
                              

                                if error? try [    write-io port/sub-port data length? data ][ print 
                                "error: close serwer"]
                                   ; insert port/sub-port data 
]

                            [  close port 

                              remove find system/ports/wait-list port port
                               close port/sub-port

                              remove find system/ports/wait-list port/sub-port port/sub-port
                              print "close connetion client"

                               print length? system/ports/wait-list
                               ]

               false]




       
   


  
response: func [ port e a /local data  f  ] 

               [  switch e [ open [ insert port port/date ]
                                    
                             read [ data: copy/part port a

                                   either ( a <> 8 ) [write-io port/sub-port data length? data] 

                                                     [  insert tail system/ports/wait-list  port/sub-port ]
                                    ]
                                     
                             close [ close port 

                                     remove find system/ports/wait-list port port
                                     close port/sub-port

                                     remove find system/ports/wait-list port/sub-port port/sub-port

                                       print "close connetion serwer"

                                      print length? system/ports/wait-list]
 

                          ]   ]


start: func [] [

conn: make port! tcp://:800

conn/awake: :heandler

set-modes conn [no-wait: false]

insert tail system/ports/wait-list  conn

open/no-wait/direct/binary conn ]


stop: func [][ close conn
               remove find system/ports/wait-list conn]

set-proxy: func [ h p ] [ proxy/host: h
                          proxy/port: p ]
                          


print "proxy"

lay:  layout [ backdrop blue
              across  h3  red "PROXY" f: field 145 
              return
              button green "start" [ p: parse f/text  ":"
                                     remove find p "" 

                                     set-proxy  to-tuple p/1  to-integer p/2
                                     source p
                                    
                                     start]
              button  green "stop" [f/text: "" stop ] ]

view/offset lay 4x29 
halt
I ask about help .
to improve someone  this programme maybe ?
in order to he was better .