www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - I need to use delete as the method name. But now it's still a keyword,

reply zoujiaqing <zoujiaqing gmail.com> writes:
https://dlang.org/changelog/2.100.0.html#deprecation_delete

My code:

```D
import std.stdio;

class HttpClient
{
	string get(string url)
	{
		return "";
	}

	string delete(string url)
	{
		return "";
	}
}

void main()
{
	auto http = new HttpClient;
	
	string content = 
http.get("https://forum.dlang.org/group/general");
	string content = 
http.delete("https://forum.dlang.org/newpost/general?");
}
```

error message
```bash
% dub build --compiler=dmd
Performing "debug" build using dmd for x86_64.
test ~master: building configuration "application"...
source/app.d(10,9): Error: no identifier for declarator `string`
source/app.d(10,9): Error: declaration expected, not `delete`
source/app.d(14,1): Error: unmatched closing brace
dmd failed with exit code 1.
```

I wonder when I can use it. Because this will cause a software 
naming problem.
May 17 2022
parent reply bauss <jj_1337 live.dk> writes:
On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote:
 https://dlang.org/changelog/2.100.0.html#deprecation_delete

 My code:

 ```D
 import std.stdio;

 class HttpClient
 {
 	string get(string url)
 	{
 		return "";
 	}

 	string delete(string url)
 	{
 		return "";
 	}
 }

 void main()
 {
 	auto http = new HttpClient;
 	
 	string content = 
 http.get("https://forum.dlang.org/group/general");
 	string content = 
 http.delete("https://forum.dlang.org/newpost/general?");
 }
 ```

 error message
 ```bash
 % dub build --compiler=dmd
 Performing "debug" build using dmd for x86_64.
 test ~master: building configuration "application"...
 source/app.d(10,9): Error: no identifier for declarator `string`
 source/app.d(10,9): Error: declaration expected, not `delete`
 source/app.d(14,1): Error: unmatched closing brace
 dmd failed with exit code 1.
 ```

 I wonder when I can use it. Because this will cause a software 
 naming problem.
Considering the deprecation period has ended then IMO it should be able to be used as an identifier. I would consider this a bug.
May 17 2022
next sibling parent zoujiaqing <zoujiaqing gmail.com> writes:
On Wednesday, 18 May 2022 at 06:13:45 UTC, bauss wrote:
 Considering the deprecation period has ended then IMO it should 
 be able to be used as an identifier.

 I would consider this a bug.
I hope this is a bug ;)
May 18 2022
prev sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 5/18/22 2:13 AM, bauss wrote:
 On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote:
 https://dlang.org/changelog/2.100.0.html#deprecation_delete

 My code:

 ```D
 import std.stdio;

 class HttpClient
 {
     string get(string url)
     {
         return "";
     }

     string delete(string url)
     {
         return "";
     }
 }

 void main()
 {
     auto http = new HttpClient;

     string content = http.get("https://forum.dlang.org/group/general");
     string content = 
 http.delete("https://forum.dlang.org/newpost/general?");
 }
 ```

 error message
 ```bash
 % dub build --compiler=dmd
 Performing "debug" build using dmd for x86_64.
 test ~master: building configuration "application"...
 source/app.d(10,9): Error: no identifier for declarator `string`
 source/app.d(10,9): Error: declaration expected, not `delete`
 source/app.d(14,1): Error: unmatched closing brace
 dmd failed with exit code 1.
 ```

 I wonder when I can use it. Because this will cause a software naming 
 problem.
Considering the deprecation period has ended then IMO it should be able to be used as an identifier. I would consider this a bug.
No, it's intentional. https://dlang.org/changelog/2.100.0.html#deprecation_delete
 Starting with this release, using the delete *keyword* will result in 
a *compiler error*. It's still a keyword according to that. I'm assuming a future release will remove the error, and then you can use it as a symbol. -Steve
May 18 2022
next sibling parent zoujiaqing <zoujiaqing gmail.com> writes:
On Wednesday, 18 May 2022 at 15:33:09 UTC, Steven Schveighoffer 
wrote:
 On 5/18/22 2:13 AM, bauss wrote:
 On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote:
 https://dlang.org/changelog/2.100.0.html#deprecation_delete

 My code:

 ```D
 import std.stdio;

 class HttpClient
 {
     string get(string url)
     {
         return "";
     }

     string delete(string url)
     {
         return "";
     }
 }

 void main()
 {
     auto http = new HttpClient;

     string content = 
 http.get("https://forum.dlang.org/group/general");
     string content = 
 http.delete("https://forum.dlang.org/newpost/general?");
 }
 ```

 error message
 ```bash
 % dub build --compiler=dmd
 Performing "debug" build using dmd for x86_64.
 test ~master: building configuration "application"...
 source/app.d(10,9): Error: no identifier for declarator 
 `string`
 source/app.d(10,9): Error: declaration expected, not `delete`
 source/app.d(14,1): Error: unmatched closing brace
 dmd failed with exit code 1.
 ```

 I wonder when I can use it. Because this will cause a 
 software naming problem.
Considering the deprecation period has ended then IMO it should be able to be used as an identifier. I would consider this a bug.
No, it's intentional. https://dlang.org/changelog/2.100.0.html#deprecation_delete
 Starting with this release, using the delete *keyword* will
result in a *compiler error*. It's still a keyword according to that. I'm assuming a future release will remove the error, and then you can use it as a symbol. -Steve
The body is now available, and hopefully the delete keyword will be deprecated soon.
May 18 2022
prev sibling parent bauss <jj_1337 live.dk> writes:
On Wednesday, 18 May 2022 at 15:33:09 UTC, Steven Schveighoffer 
wrote:
 On 5/18/22 2:13 AM, bauss wrote:
 On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote:
 https://dlang.org/changelog/2.100.0.html#deprecation_delete

 My code:

 ```D
 import std.stdio;

 class HttpClient
 {
     string get(string url)
     {
         return "";
     }

     string delete(string url)
     {
         return "";
     }
 }

 void main()
 {
     auto http = new HttpClient;

     string content = 
 http.get("https://forum.dlang.org/group/general");
     string content = 
 http.delete("https://forum.dlang.org/newpost/general?");
 }
 ```

 error message
 ```bash
 % dub build --compiler=dmd
 Performing "debug" build using dmd for x86_64.
 test ~master: building configuration "application"...
 source/app.d(10,9): Error: no identifier for declarator 
 `string`
 source/app.d(10,9): Error: declaration expected, not `delete`
 source/app.d(14,1): Error: unmatched closing brace
 dmd failed with exit code 1.
 ```

 I wonder when I can use it. Because this will cause a 
 software naming problem.
Considering the deprecation period has ended then IMO it should be able to be used as an identifier. I would consider this a bug.
No, it's intentional. https://dlang.org/changelog/2.100.0.html#deprecation_delete
 Starting with this release, using the delete *keyword* will
result in a *compiler error*. It's still a keyword according to that. I'm assuming a future release will remove the error, and then you can use it as a symbol. -Steve
To be honest, it's not clear that it's intentional from the description of the changelog. It just says using the keyword will result in an error, not using the keyword as an identifier, which isn't the same at all.
May 18 2022