Hi Tim,

1. safe-close:

>similarly a function like
>safe-close: func [p[port!]][if p [close p]]
>
>generates an error message.

Since you only permit port! as the argument's datatype, and none is of type
none! and not port!, you shouldn't be too surprised! ;-)

Try 

safe-close: func [p[port! none!]][if p [close p]]

>> safe-close: func [p[port! none!]][if p [close p]]
>> safe-close dufus-pointer
== false

2. equal? dufus-pointer none ...
max's idea, to use port?, should certainly work (and is the cleaner way to
do it anyway).

It bothers me, however, that your code fails. The code you present should
work as expected, as can easily be tested in the REBOL shell:

>> dufus-pointer: none
== none
>> equal? dufus-pointer none
== true

I can think of three reasons why this could happen:
1. the error is not being generated by the code you presented;
2. dufus-pointer is being set (unexepctedly!) to some non-port value
somewhere in your program. This possibility should worry you! ;-)
3. One of the two none values is not a none value. It is a word value. For
instance:
>> a: none
== none
>> b: first [none]
== none
>> none? a
== true
>> none? b
== false
>> type? a
== none!
>> type? b
== word!


At 08:44 PM 5/22/00 -0800, you wrote:
>I'm sending this again.... Are we having problems with
>the mailing list again?
>==========================================================
>I'm setting up an object that contains some ports,
>which may or may not be open. 
>i.e.: may or may not open "test.txt"
>      may or may not open "dufus.txt"
>obviously I don't want to attempt to close
>what I didn't open.
>If I initialize a word to none
>as dufus-pointer: none
>and don't open it.
>the following code:
>either equal? dufus-pointer none [][close dufus-pointer]
>  generates an error: expected argument of type: port
>
>similarly a function like
>safe-close: func [p[port!]][if p [close p]]
>
>generates an error message.
>
>How can I get around this?
>
>
>Thanks Folks!
>Tim
>
>
>

;- Elan >> [: - )]

Reply via email to