Hacker News new | ask | show | jobs
by blacksqr 591 days ago
> does not distinguish directories from files (e.g. Tcl)

Tcl has the built-in functions [file exists], [file isdirectory] and [file isfile] to serve your existence-checking needs.

1 comments

I know. So does VB. This is precisely my point.

GP complains that there is no direct function for "file exist". And technically there is not on Tcl either because file exists cmd will return true for directories. You can trivially build your proc that specifically checks for files (it will likely use isfile) but that is exactly the point of my comment. I have shown how do that for VB and it is not far from a one liner.

Presence/absence of a file exists function is a very poor example. If the language didn't allow you to check e.g. if a file was a directory or not, then GP might had have a point. But this is not the case.

[glob -nocomplain -type f <Filename>]
There's nothing wrong with [file isfile $filename] either. As I'm saying there's a million of oneliners for it.

I am not sure if I'm getting my point clear. I'm presuming you are trying to defend that yes, you can check if a file exists in Tcl, even if there's no specific function for it, but that is, again, exactly my point. Like what you're doing, I've shown many ways to do it in VB.

I guess the fact that someone needs to nitpick me in exactly the same way I was nitpicking the GP is quite the proof that the analogy works perfectly...