You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EXISTS? as it is now can only be used as a logical predicate, telling you whether the file exists. However, the underlying QUERY function also returns whether the file is a file or a directory in the type field of the returned info object. Instead of throwing away that information, return it. This would save us from having to run QUERY again inside the DIR? function to get that info back. Additional QUERY calls can have measurable overhead on networked resources.
If we change the code in EXISTS? from [found? attempt [query target]] to [select attempt [query target] 'type] then EXISTS? will return the type of the file as a word if it exists, but none if it doesn't. This will allow EXISTS? to still be used in logical predicate situations (except AND and OR), while providing more info to those who need it.
EXISTS? not working with AND and OR is not likely to be a problem as most programmers use EXISTS? with ALL or ANY instead. You can still use FOUND? if you need a logic! value.
; Old usageif exists? %something [do something]
unlessall [exists? f not dir? f] [error handling]
; New usageif exists? %something [do something]
unless 'file = exists? f [error handling]
This would also be a good candidate for the R2-Future backports, as the underlying code would be quite different between R2 and R3. Which means that the equivalent replacement code would need a lot of special casing, due to the changes in QUERY and DIR?. This change would make it easier to write code that will run on R2 and R3.
Implemented in mezz-file 575 and r2-forward 574.
Rebolbot added the Type.wish on Jan 12, 2016
The text was updated successfully, but these errors were encountered:
Submitted by: BrianH
EXISTS? as it is now can only be used as a logical predicate, telling you whether the file exists. However, the underlying QUERY function also returns whether the file is a file or a directory in the type field of the returned info object. Instead of throwing away that information, return it. This would save us from having to run QUERY again inside the DIR? function to get that info back. Additional QUERY calls can have measurable overhead on networked resources.
If we change the code in EXISTS? from [found? attempt [query target]] to [select attempt [query target] 'type] then EXISTS? will return the type of the file as a word if it exists, but none if it doesn't. This will allow EXISTS? to still be used in logical predicate situations (except AND and OR), while providing more info to those who need it.
EXISTS? not working with AND and OR is not likely to be a problem as most programmers use EXISTS? with ALL or ANY instead. You can still use FOUND? if you need a logic! value.
Imported from: CureCode [ Version: alpha 33 Type: Wish Platform: All Category: n/a Reproduce: Always Fixed-in:alpha 37 ]
Imported from: metaeducation#612
Comments:
Submitted by: BrianH
This would also be a good candidate for the R2-Future backports, as the underlying code would be quite different between R2 and R3. Which means that the equivalent replacement code would need a lot of special casing, due to the changes in QUERY and DIR?. This change would make it easier to write code that will run on R2 and R3.
Implemented in mezz-file 575 and r2-forward 574.
The text was updated successfully, but these errors were encountered: