Menu

#661 Allow "do over .nil"

None
unread
nobody
None
none
1
2015-10-18
2015-03-18
Erich
No

When a method or a function that normally returns a collection object, returns .nil as an exceptional case, it would often come handy if
do item over .nil
worked as an empty loop.
(I assume that's equivalent to asking .nil~makeArray to return a zero-size array)

Related

Feature Requests: #661

Discussion

  • Moritz Hoffmann

    Moritz Hoffmann - 2015-04-23

    Hi Erich,
    I do not understand what you want to achieve with this. Do you want to bind the variable item to the value .nil for one iteration or do you want to the loop to do nothing at all? The first case can be achieved by iterating over a supplier that just supplies a single value, .nil. The latter would not make much sense either I think.
    Best,
    Moritz

     
  • Moritz Hoffmann

    Moritz Hoffmann - 2015-04-23
    • status: unread --> pending
    • Milestone: 5.0.0 --> None
     
  • Rick McGuire

    Rick McGuire - 2015-04-23

    I suspect Erich's desire is .nil will go for zero iterations. This covers the case where a method return value is either an array of items or .nil if there are no items available.

     
    • Erich

      Erich - 2015-04-23

      I suspect Erich's desire is .nil will go for zero iterations

      Yes, that's what I meant.

      Here's an example. It would be nice (and more REXX-ish?) if you could code:

      files = .File~new(directory)~listFiles
      do file over files
        ..
      end
      

      without having to protect the do .. loop with:

      if files \== .nil then ..
      

      Above RFE was only one of the have-to-check-nil situations, I sometimes run
      into. Another one might be:

      file = .File~new(..)
      earliestDate = .DateTime~new~addDays(-30)
      date = file~lastModified
      if date < earliestDate then ..
      

      Again, you have to protect the "if" with "if date \== .nil .:"

      On Thu, Apr 23, 2015 at 3:32 PM, Rick McGuire bigrixx@users.sf.net wrote:

      I suspect Erich's desire is .nil will go for zero iterations. This covers
      the case where a method return value is either an array of items or .nil if
      there are no items available.


      Status: pending
      Milestone: None
      Created: Wed Mar 18, 2015 10:27 AM UTC by Erich
      Last Updated: Thu Apr 23, 2015 01:29 PM UTC
      Owner: nobody

      When a method or a function that normally returns a collection object,
      returns .nil as an exceptional case, it would often come handy if
      do item over .nil
      worked as an empty loop.
      (I assume that's equivalent to asking .nil~makeArray to return a zero-size
      array)


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/oorexx/feature-requests/661/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Feature Requests: #661

  • Erich

    Erich - 2015-10-18
    • status: pending --> unread
     

Anonymous
Anonymous

Add attachments
Cancel