Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Implement more property syntax enforcement #968

Closed
wants to merge 5 commits into from

4 participants

Hara Kenji David Nadlinger Andrei Alexandrescu Jonathan M Davis
Hara Kenji
Collaborator

Requires: dmd/pull/1311

See commit message for more details.

David Nadlinger
Collaborator

We'd better drop @property from std.file.exists – requiring the function to be called as a string property is definitely weird, and entirely inconsistent with the rest of the file functions. Note that it was marked up with the attribute long before the currently discussed language changes…

Hara Kenji
Collaborator

Now dmd/pull/1311 is closed, then close this.

Hara Kenji 9rnsr closed this
Hara Kenji 9rnsr referenced this pull request
Merged

Tweak for properties #978

Hara Kenji
Collaborator

Opened spin-out pull #978 from here.

jmdavis and others added some commits
Jonathan M Davis jmdavis Merge pull request #978 from 9rnsr/tweak_properties
Tweak for properties
47e6293
Hara Kenji 9rnsr Remove remain redundant parenthesis.
This change requires following two compiler fixes.
- Issue 9062 - AddrExp should distinguish the existence of property resolution.
e70d8d8
Hara Kenji 9rnsr Except opDollar, we should not mark member functions for operator ove…
…rloading as properties.
6aa0c15
Hara Kenji 9rnsr We should always call std.file.exists by UFCS.
std.file.exists is a module level property function that receives one argument.
With new property enforcement mechanism, we cannot call it with normal function syntax (has parenthesis).
1c618f3
Hara Kenji 9rnsr Remove @property attribute from std.file.exists, instead of enforcing…
… UFCS property usage
51aaf81
Hara Kenji 9rnsr reopened this
Hara Kenji
Collaborator

Reopened. Most changes which had been unrelated to compiler fix were separately merged by #978.

Hara Kenji 9rnsr referenced this pull request in D-Programming-Language/dmd
Closed

Implement more property syntax enforcement #1311

Andrei Alexandrescu
Owner

This pull makes sense, but it's time to overhaul the entire approach to properties. Let's hold back on it for a while.

Hara Kenji 9rnsr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 2, 2012
  1. Jonathan M Davis

    Merge pull request #978 from 9rnsr/tweak_properties

    jmdavis authored
    Tweak for properties
Commits on Dec 3, 2012
  1. Hara Kenji

    Remove remain redundant parenthesis.

    9rnsr authored
    This change requires following two compiler fixes.
    - Issue 9062 - AddrExp should distinguish the existence of property resolution.
  2. Hara Kenji
  3. Hara Kenji

    We should always call std.file.exists by UFCS.

    9rnsr authored
    std.file.exists is a module level property function that receives one argument.
    With new property enforcement mechanism, we cannot call it with normal function syntax (has parenthesis).
  4. Hara Kenji
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 10 deletions.
  1. +3 −3 std/algorithm.d
  2. +1 −1  std/file.d
  3. +4 −6 std/range.d
6 std/algorithm.d
View
@@ -1133,17 +1133,17 @@ void initializeAll(Range)(Range range)
if (isForwardRange!Range && is(typeof(range.front = range.front)))
{
alias ElementType!Range T;
- static assert(is(typeof(&(range.front()))) || !hasElaborateAssign!T,
+ static assert(is(typeof(&(range.front))) || !hasElaborateAssign!T,
"Cannot initialize a range that does not expose"
" references to its elements");
static if (!isDynamicArray!Range)
{
- static if (is(typeof(&(range.front()))))
+ static if (is(typeof(&(range.front))))
{
// Range exposes references
for (; !range.empty; range.popFront())
{
- memcpy(&(range.front()), &T.init, T.sizeof);
+ memcpy(&(range.front), &T.init, T.sizeof);
}
}
else
2  std/file.d
View
@@ -759,7 +759,7 @@ unittest
/++
Returns whether the given file (or directory) exists.
+/
-@property bool exists(in char[] name)
+bool exists(in char[] name)
{
version(Windows)
{
10 std/range.d
View
@@ -1784,8 +1784,7 @@ unittest
assert(s1[1..5].length == 4);
assert(s1[0..0].empty);
assert(s1[3..3].empty);
- // assert(s1[$ .. $].empty);
- assert(s1[s1.opDollar() .. s1.opDollar()].empty);
+ assert(s1[$ .. $].empty);
auto s2 = stride(arr, 2);
assert(equal(s2[0..2], [1,3]));
@@ -1794,8 +1793,7 @@ unittest
assert(s2[1..5].length == 4);
assert(s2[0..0].empty);
assert(s2[3..3].empty);
- // assert(s2[$ .. $].empty);
- assert(s2[s2.opDollar() .. s2.opDollar()].empty);
+ assert(s2[$ .. $].empty);
// Test fix for Bug 5035
auto m = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]; // 3 rows, 4 columns
@@ -6377,7 +6375,7 @@ ElementType!R moveFront(R)(R r)
return r.moveFront();
} else static if (!hasElaborateCopyConstructor!(ElementType!R)) {
return r.front;
- } else static if (is(typeof(&(r.front())) == ElementType!R*)) {
+ } else static if (is(typeof(&(r.front)) == ElementType!R*)) {
return move(r.front);
} else {
static assert(0,
@@ -6409,7 +6407,7 @@ ElementType!R moveBack(R)(R r)
return r.moveBack();
} else static if (!hasElaborateCopyConstructor!(ElementType!R)) {
return r.back;
- } else static if (is(typeof(&(r.back())) == ElementType!R*)) {
+ } else static if (is(typeof(&(r.back)) == ElementType!R*)) {
return move(r.back);
} else {
static assert(0,
Something went wrong with that request. Please try again.