#616 Change in stream 'query datetime'

v4.0beta
closed
Mark Miesfeld
5
2012-08-14
2009-04-16
Mike Cowlishaw
No

There is a change in behaviour in stream 'query datetime'.  In this
little program:

outdir='foo'
  say 'DT:' stream(outdir, 'c', 'query datetime')
  say 'EX:' stream(outdir, 'c', 'query exists')

then if 'foo' is a directory and does exist then

in 3.20 the first call returns a datetime and the second call returns ''
  in 4.00 they both return ''

In this case I think 4.00 is probably correct as it is consistent.  Changing
the behaviour of query exists would probably break lots....

Also I see the new SysFileExists returns 1 for both and existing file and an
existing directory, so that behaviour is now available anyway.

Suggestion:

1) Document this change of behaviour in the readme file.

2) Add to Stream documentation (and also the new functions) that a directory is not a 'persistent stream' or 'file'. (Hmm, so is 'SysFileIsDir' the right name for that function?)

Discussion

  • Mark Miesfeld
    Mark Miesfeld
    2009-04-20

    Mike, I went to do a doc update, but I'm a little confused here now. Which Rick can tell you happens often.

    As of now, the behavior of your program is the same in 4.0.0 as it is in 3.2.0. So, I don't think any change needs to be done to the readme.

    E:>rexx -v
    Open Object Rexx Interpreter Version 3.2.0
    ...
    E:>
    E:>query.rex
    query bin (does exist.)
    DT: 12-13-08 10:27:14
    EX:
    query foo (does not exist.)
    DT:
    EX:

    E:>

    C:>rexx -v
    Open Object Rexx Version 4.0.0
    ...
    C:>
    C:>query.rex
    query bin (does exist.)
    DT: 09-21-08 20:12:56
    EX:
    query foo (does not exist.)
    DT:
    EX:

    I happen to think the behavior for directories for query exists is wrong. If we can query its date / time, we should be able to query if it exists.

    But as you say, changing the behavior of query exists is likely to break programs. But, changing the behavior of query datetime is also likely to break some programs, probably not as many, but still..

    Since the behavior is the same, I'm not sure a change to the docs should be done. I could put in a note for the query exists that a directory is not technically a stream so the empty string is returned for query exists of an existing directory. However, that just draws attention to the fact that the behavior of query datetime is not consistent.

    All in all, I think it is better to just leave the doc as is.

    However, if I am confused, <grin> then feel free to straighten me out. Or of course Rick can straighten me out, he does it quite often.

     
  • Rick McGuire
    Rick McGuire
    2009-04-20

    Mike's complaint was the fact the behavior of neither of these functions is documented in this situation. The behavior is definitely inconsistent, but I don't see any real overwhelming argument that compatibility should be broken. Once you've made that choice, we should document how they actually behave in those situations.

     
  • Mark Miesfeld
    Mark Miesfeld
    2009-04-21

    Okay Rick. I'll do a doc update sometime today for how they actually behave.

     
  • Mike Cowlishaw
    Mike Cowlishaw
    2009-04-22

    Ah OK, I hadn't realized/noticed that q datetime behaviour is now back to as it was in 3.20. OK, that makes sense (minimum breakage). And yes a little clarification in the docs would be helpful.

    Mike

     
  • Mark Miesfeld
    Mark Miesfeld
    2009-04-22

    There is one other discrepency between 3.2.0 and 4.0.0. 4.0.0 returns a 0 for query handle and 3.2.0 returned the empty string:

    outdir='bin'
    say 'query bin (does exist.)'
    say 'DT:' stream(outdir, 'c', 'query datetime')
    say 'EX:' stream(outdir, 'c', 'query exists')
    say 'EX:' stream(outdir, 'c', 'query handle')
    say 'EX:' stream(outdir, 'c', 'query seek')
    say 'EX:' stream(outdir, 'c', 'query position')
    say 'EX:' stream(outdir, 'c', 'query size')
    say 'EX:' stream(outdir, 'c', 'query streamtype')
    say 'EX:' stream(outdir, 'c', 'query timestamp')

    E:>rexx -v
    Open Object Rexx Interpreter Version 3.2.0

    E:>query
    query bin (does exist.)
    DT: 12-13-08 10:27:14
    EX:
    EX:
    EX:
    EX:
    EX: 0
    EX: UNKNOWN
    EX: 2008-12-13 10:27:14
    query foo (does not exist.)
    DT:
    EX:
    EX:
    EX:
    EX:
    EX:
    EX: UNKNOWN
    EX:

    C:>rexx -v
    Open Object Rexx Version 4.0.0

    C:>query
    query bin (does exist.)
    DT: 09-21-08 20:12:56
    EX:
    EX: 0
    EX:
    EX:
    EX: 0
    EX: UNKNOWN
    EX: 2008-09-21 20:12:56
    query foo (does not exist.)
    DT:
    EX:
    EX: 0
    EX:
    EX:
    EX:
    EX: UNKNOWN
    EX:

     
  • Rick McGuire
    Rick McGuire
    2009-04-22

    Committed revision 4473.

    query handle now has compatible behavior. Null string is returned for unopened streams, and a numeric value for open streams.

     
  • Mark Miesfeld
    Mark Miesfeld
    2009-04-22

    Committed revision 4477.

    That commit updates the doc to explicitly state what the stream query commands return for a directory.

     
  • Mike Cowlishaw
    Mike Cowlishaw
    2009-04-24

    (Haven't actually seen latest doc, but taking your word for it to close one more 'artifact'.)

     


Anonymous


Cancel   Add attachments