4 ms·
Isn't this quite common? Most languages allow you to represent those strings as different types and parse them/to from a plain string representation. From Ruby
by grey-area 11y ago
Isn't this quite common? Most languages allow you to represent those strings as different types and parse them/to from a plain string representation.
From Ruby: String, Pathname, Url, ActiveRecord::Relation etc or from Go: strings, database/sql stmt + orm types built on top, net/url etc though file paths are just strings.
- MrBuddyCasino 11y agoIt is, even Java does that. Where it gets interesting is advanced trickery, as performed by Haskell. You can have a type String that cares of escaping/unescaping stuff that comes from tainted sources in a webapp, eliminating a whole lot of security issues. Thats just one example I know, but I'm not a Haskell guy - there are surely more.
- mozumder 11y agoYep. He basically just described "classes" in the object-oriented world.
- tokenrove 11y agoI don't think it has much to do with classes. Python, for example, has no pathname/string distinction that I know of. Common Lisp is in the object-oriented world, and indeed some of the things mentioned are implemented as classes. I think the point was more about the standard library's attempt to do The Right Thing and how library implementors tend to follow that. (Also, for better or for worse, CL's pathnames contain information like host, device, and version, that aren't so relevant on the major OSes in use these days; but try dealing with VMS filenames with Ruby's Pathname...)
- lispm 11y agoDevice and even host are quite common in the Windows world: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa3... Volume = Device Or Microsoft's UNC path: https://en.wikipedia.org/wiki/Path_(computing)#Uniform_Naming_Convention https://en.wikipedia.org/wiki/Path_(computing)#Uniform_Namin... \\ComputerName\SharedFolder\Resource -> \\host\device\path