#473 String compares should have special exception for .nil

Classes (154)

Currently, the string implementations of comparison operations unconditionally convert the right-hand-side of the comparison to a string value. This means compares like

if arg == .nil then ....

If the variable arg is .nil, then these objects are compared directly. If variable arg is a string value, .nil gets converted to the string "The NIL object" and this value is compared. This has two problems:

1) There is a potential for a false positive on this compare if the string value happens to be the string "The NIL object"
2) a NOSTRING condition is raised, which causes unexpected problems if SIGNAL ON ANY is in use.

The workaround is to code "if .nil == arg then ..." to get .nil on the left side of the operator. In practice, people almost universally prefer the first form. Comparison to .nil is such an important thing on the ooRexx language that the string class should recognize .nil as a special case and always return .false (avoiding the NOSTRING condition as well).


Feature Requests: #457


  • Rick McGuire

    Rick McGuire - 2012-08-21
    • status: open --> accepted
    • assigned_to: Rick McGuire
    • pending_work_items: --> code+doc+test
    • milestone: --> v4.2.0
  • Rick McGuire

    Rick McGuire - 2012-08-22
    • status: accepted --> pending
    • pending_work_items: code+doc+test --> complete
  • Rick McGuire

    Rick McGuire - 2012-08-27

    Some fixes for this feature

    code: [r8286]
    test: [r8287]



    Commit: [r8286]
    Commit: [r8287]

  • Rick McGuire

    Rick McGuire - 2014-04-15
    • status: pending --> closed


Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks