www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5707] New: cannot overload both property and non-property functions

http://d.puremagic.com/issues/show_bug.cgi?id=5707

           Summary: cannot overload both property and non-property
                    functions
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jmdavisProg gmx.com



PST ---
For some reason, with the current dmd, it is not legal to two overloads of a
function where one is a property and one is not. I do not understand why this
is so, and I've definitely run into cases where it's annoying. I'd _really_
like it  to be legal to overload a function such that it's a property for one
type and not for another.

A prime example of this is in std.file. There are a number of property
functions in there related to getting information on a file: isFile, isDir,
etc. Normally, you use the version which takes a string - the path of the file.
It makes perfect sense for it to be a property (e.g. if(filename.isFile){...}
). However, there are also versions of those functions which take a uint of the
attributes for that file as returned by getAttributes. It makes perfect sense
to have a versions of isFile, isDir, etc. which take the file attributes and
tell you whether they represent a file, or directory, or whatever. However, it
strikes me as undesirable (and currently illegal due to the lack of UFCS) to do
something like attributes.isFile. I'd much prefer to have it called as
isFile(attributes) (which is how you currently have to call it anyway). But the
fact that you can't overload properties with non-properties means that for the
moment, _both_ overloads of all of these functions are marked as property
functions.

I would _really_ like to be able to have the string functions be properties and
the uint versions _not_ be properties. But the fact that dmd currently gives an
error like this

std/file.d(1253): Error: cannot overload both property and non-property
functions

when you try and do that makes it kind of hard. So, I'd _definitely_ like it if
you could overload functions such that some overloads are properties and some
aren't.

If this isn't fixed, and we don't get UFCS before the syntax for calling
 property functions is enforced, then calling the overloads for the functions
in std.file which take the attributes will become illegal. Either dmd needs to
be changed so that it's legal to overload property functions with non-property
functions, or I'm going to have to go and change it so that isDir, isFile, etc.
for attributes are renamed to something else so that they can be non-property
functions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 05 2011