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.

JohanAR
14-Mar-2008
[1379x2]
thanks!
On to the next question :) Why is '= valid but '< or '> aren't?
Geomol
14-Mar-2008
[1381x2]
My guess is, that it's becuase < and > are part of tag type, like 
<tag>. So it's a restriction to make value evaluation easier internally.
>> blk: [=]
== [=]
>> blk: [<]
** Syntax Error: Invalid tag -- <
** Near: (line 1) blk: [<]
>> blk: [<tag>]
== [<tag>]
BrianH
14-Mar-2008
[1383]
>> type? first [<]
** Syntax Error: Invalid tag -- <
** Near: (line 1) type? first [<]
>> type? first [ < ]
== word!
Geomol
14-Mar-2008
[1384]
hehe, funny! :)
BrianH
14-Mar-2008
[1385x4]
I guess it is special-cased in the loader.
>> attempt [[<]]
** Syntax Error: Invalid tag -- <
** Near: (line 1) attempt [[<]]
>> attempt [load "[<]"]
== none
This relates to the sandboxing discussion I was just having with 
Paul.
The first error isn't caught because the load happens before the 
attempt is called.
JohanAR
14-Mar-2008
[1389]
you can ofcourse use to-word "<" but it's not very good looking if 
you have to cover all of <, <=, >, >=, <> etc.. managed to avoid 
the case by using compose instead of reduce though
JohanAR
15-Mar-2008
[1390]
Is it possible to define a function, which takes another function 
as argument and that the argument func must take exactly two arguments 
in it's turn?
PeterWood
15-Mar-2008
[1391x5]
This is how you can pass a function to a function:

>> a: func [a [function!]] [ print a 1 2]
>> b: func [x [integer!] 
y [integer!]] [add x y]
>> a :b
3
Sorry about the formatting; let my try again:
>> a: func [a [function!]] [ print a 1 2]

>> b: func [x [integer!] y [integer!]] [add x y]

>> a :b

3
I think you will need to "manually" check that the supplied function 
uses the correct number of arguments
>> c: func [a [function!]] [if 2 = length? first :a [print a 1 2]]
 
>> c :b
3
>> d: func [][print "no args"]
>> c :d

== none
JohanAR
15-Mar-2008
[1396x3]
Mm, I ended up writing something similar to that. Found out that 
I also have to check if third first :a is /local, which would also 
be a valid function
getargs: function [
	:fun "Get arguments from this function"
][
	out pblock
][
	out: make block! 10
	parse third :fun [
		some [
			string!		; Strip comments
			|

   [ [word! | get-word! | lit-word!] (pblock: [any-type!]) opt [string!] 
   opt [set pblock block!] opt [string!] (append/only out pblock) ]
		]
	]
	out
]
a little messy, but it appears to work :)
BrianH
15-Mar-2008
[1399x6]
You don't have to manually check to see if the function takes two 
arguments; this is good, because doing so is awkward. All you really 
need to do is call the function in parentheses ( ) or at the end 
of a code block, so that it can't take more than two arguments even 
if it tries. If it takes less than two arguments, who cares?
Be sure to assign the use or assign the result of the function call 
inside the parentheses, rather than outside them, in case the function 
takes less than the number of arguments you are expecting it to.
Do
    source replace
in REBOL 2.7.6 for an example of this - look for the parentheses.
The ARRAY function in 2.7.6 does the end-of-the-code-block method 
for function value arguments.
If the datatypes the function value is expecting don't match the 
data that your function is passing to it, no problem: A nice error 
message will be generated at runtime that the developer of the function 
value can use to fix their function value. :)
assign the use
 -> "use"
Gabriele
16-Mar-2008
[1405]
Carl had a nargs mezz somewhere (maybe he posted it on the ml?)
Gregg
17-Mar-2008
[1406]
http://www.fm.tul.cz/~ladislav/rebol/argstake.html
RobertS
23-Mar-2008
[1407]
; what is the rationale, I wonder of the difference
>> lit-word? first [ 'thang thing]  
== true
>> lit-word? 'thang
== false
>> type? first ['thang thing]
== lit-word!
>> type? 'thang
== word!
BrianH
23-Mar-2008
[1408]
type? first ['thang]
'thang is not being evaluated

type? 'thang

'thang is being evaluated. The result of that evaluation is a word!
Sunanda
23-Mar-2008
[1409]
.....But with 'reduce, 'thang is being evaluated, so:
    type? first reduce ['thang]
    == word!
RobertS
23-Mar-2008
[1410]
thang -ks
Henrik
26-Mar-2008
[1411]
I can't believe I missed all those REBOL tutorials available on Youtube 
by Nick Antoniacco. Here's the complete list, in case newbies missed 
them too:

http://musiclessonz.com/rebol_video_links.html
Reichart
26-Mar-2008
[1412x2]
Interesting guy http://rockfactory.us/Teachers.html
He is the top one "Nick"
Gregg
27-Mar-2008
[1414]
Didn't RT link to those from REBOL.com at some point? If not, they 
really should.
Will
27-Mar-2008
[1415]
looking at source of 'send, am I right, if there is an error executing 
send, than the port is not closed, this will leave a lot of open 
connections when batching?
BrianH
27-Mar-2008
[1416]
Ports are closed when the garbage collector gets them. If you are 
batch sending, the next time you call the SEND function it will assign 
none to the smtp-port local variable, rendering the previous reference 
assigned to that variable into garbage. The next time RECYCLE is 
run, any open ports in the garbage will be closed.
Will
27-Mar-2008
[1417x2]
ok, but between recycles, I could reach the maximum connections limit 
of the smtp server?
also, 'send should probably return a value of type logic!
BrianH
27-Mar-2008
[1419]
Recycle yourself if you're worried. Interesting idea on the return 
value.
Will
27-Mar-2008
[1420x7]
Thanks BrianH, I'm trying to find a bug, I get random port none not 
open errors but they appear randomly everywhere, only thing sure 
is they come only after using 'send , but it may be word! conflict, 
variable rewrite, etc.. just maybe someone has a better idea where 
to look for.. 8/
looks like an asynchronous event error popping in the middle of execution 
of other code, possible??
like this error:
code: 501
description: access error, Port none not open
near:
[if none? i [return none] 
either
]
where: confirm

or

code: 501
description: access error, Port none not open
near:
[if empty? block: reduce block]
where: confirm


oly thing in common, is where: confirm and that I see only in net-utils, 
any idea ?
even had a recycle..
code: 501
description: access error, Port none not open
near:
[recycle 
wait 0.2
]
where: confirm
here is the net-log, a couple of this (no problem)::

Net-log: ["Opening" "tcp" "for" "esmtp"]
Net-log: [none "220"]
Net-log: "220 domain.com running core"
Net-log: [["EHLO" system/network/host] "250"]
Net-log: {250-domain.com hello mail.local (10.5.32.4)}
Net-log: "250-PIPELINING"
Net-log: "250-8BITMIME"
Net-log: "250-BINARYMIME"
Net-log: "250-CHUNKING"
Net-log: "250-ENHANCEDSTATUSCODES"
Net-log: "250-ETRN"
Net-log: "250-AUTH CRAM-MD5 DIGEST-MD5 NTLM PLAIN LOGIN"
Net-log: "250 SIZE 2147483647"
Net-log: ["Supported auth methods:" [cram plain login]]
Net-log: ["MAIL FROM: <[majordomo-:-domain-:-com]>" "250"]
Net-log: "250 2.1.5 sender OK"
Net-log: ["RCPT TO: <[user-:-domain-:-com]>" "250"]
Net-log: "250 2.1.0 forwarding to [user-:-domain-:-com]"
Net-log: ["DATA" "354"]
Net-log: "354 send your message"
Net-log: [none "250"]
Net-log: "250 2.6.0 message received OK"
Net-log: ["QUIT" "221"]
Net-log: "221 2.0.0 domain.com closing connection"
than suddenly this one:

Net-log: ["QUIT" "221"]
Net-log: ["Opening" "tcp" "for" "esmtp"]
Net-log: [none "220"]
Net-log: "220 domain.com running core"
Net-log: [["EHLO" system/network/host] "250"]
Net-log: {250-domain.com hello mail.local (10.5.32.4)}
Net-log: "250-PIPELINING"
Net-log: "250-8BITMIME"
Net-log: "250-BINARYMIME"
Net-log: "250-CHUNKING"
Net-log: "250-ENHANCEDSTATUSCODES"
Net-log: "250-ETRN"
Net-log: "250-AUTH CRAM-MD5 DIGEST-MD5 NTLM PLAIN LOGIN"
Net-log: "250 SIZE 2147483647"
Net-log: ["Supported auth methods:" [cram plain login]]
Net-log: ["MAIL FROM: <[admin-:-domain-:-com]>" "250"]
Net-log: "250 2.1.5 sender OK"
Net-log: ["RCPT TO: <[user-:-domain-:-com]>" "250"]
Net-log: "250 2.1.0 forwarding to [user-:-domain-:-com]"
Net-log: ["DATA" "354"]
Net-log: "354 send your message"
Net-log: [none "250"]
Net-log: "250 2.6.0 message received OK"
Net-log: ["QUIT" "221"]
Net-log: "221 2.0.0 domain.com closing connection"


error code: 501
description: access error, Port none not open
near: [value: either series? :value [copy value]]
where: confirm
note the difference that seams to trigger the problem is the first 
line, the 'quit, where does it come from?
Gabriele
28-Mar-2008
[1427x2]
;-- Send as an SMTP batch or individually addressed:
        smtp-port: open [scheme: 'esmtp]
        either only [ ; Only one message to multiple addrs
                address: copy address
                ; remove non-email values
                remove-each value address [not email? :value]

                message: head insert insert tail net-utils/export header-obj newline 
                m
essage
                insert smtp-port reduce [from address message]
        ] [
                foreach addr address [
                        if email? addr [

                                if not show [insert clear header-obj/to addr]

                                tmp: head insert insert tail net-utils/export header-o
bj newline message

                                insert smtp-port reduce [from reduce [addr] tmp]
                        ]
                ]
        ]
        close smtp-port
the port is closed in the last line of send - am i missing something?