www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Idea for getting rid of "static" on methods

reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Nobody likes how overused static is, so here's an idea for a syntax to 
replace it in one place where it is frequently seen.

Here it goes:

    (with out this) int my_method() {...}

badum -ching!

--bb
Nov 30 2007
next sibling parent reply "Craig Black" <cblack ara.com> writes:
"Bill Baxter" <dnewsgroup billbaxter.com> wrote in message 
news:fipjds$cft$1 digitalmars.com...
 Nobody likes how overused static is, so here's an idea for a syntax to 
 replace it in one place where it is frequently seen.

 Here it goes:

    (with out this) int my_method() {...}

 badum -ching!

 --bb
What are you joking about? Did someone suggest getting rid of static?
Nov 30 2007
next sibling parent "Janice Caron" <caron800 googlemail.com> writes:
On 11/30/07, Craig Black <cblack ara.com> wrote:
 What are you joking about?
I'm sure he's joking. He's figured out that "with", "out" and "this" are all keywords, and when put together make a readable phrase. :) It's really quite clever, but I'd be surprised if it was a serious suggestion.
Nov 30 2007
prev sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Craig Black wrote:
 "Bill Baxter" <dnewsgroup billbaxter.com> wrote in message 
 news:fipjds$cft$1 digitalmars.com...
 Nobody likes how overused static is, so here's an idea for a syntax to 
 replace it in one place where it is frequently seen.

 Here it goes:

    (with out this) int my_method() {...}

 badum -ching!

 --bb
What are you joking about? Did someone suggest getting rid of static?
Not recently, but it always comes up top on the list of confusingly overused keywords. I was just thinking about it a little because adding const(this) would kind of make static stick out. I was trying to think of some way static on methods could be made more parallel with const(this). Something like no(this) was the first thing that came to mind, but that's not a keyword so I went trolling through the keyword index to see if there was anything else suitable. But the best I could come up with sounded more like a feeble attempt at humor than a real solution. --bb
Nov 30 2007
parent reply Matti Niemenmaa <see_signature for.real.address> writes:
Bill Baxter wrote:
 Something like no(this) was the first thing that came to mind, but that's not
 a keyword so I went trolling through the keyword index to see if there was 
 anything else suitable.
How about: (!this) int my_method() {...} (!in this) int my_method() {...} (with !this) int my_method() {...} (!with this) int my_method() {...} (is !in this) int my_method() {...} (!is in this) int my_method() {...} (this !is in this) int my_method() {...} (this is !in this) int my_method() {...} Where in the latter two, the first 'this' of course refers to the method. -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Nov 30 2007
next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Matti Niemenmaa wrote:
 Bill Baxter wrote:
 Something like no(this) was the first thing that came to mind, but that's not
 a keyword so I went trolling through the keyword index to see if there was 
 anything else suitable.
How about: (!this) int my_method() {...} (!in this) int my_method() {...} (with !this) int my_method() {...} (!with this) int my_method() {...} (is !in this) int my_method() {...} (!is in this) int my_method() {...} (this !is in this) int my_method() {...} (this is !in this) int my_method() {...} Where in the latter two, the first 'this' of course refers to the method.
Now you're on to something! Just tweak that last one slightly: (this is !in function) int my_method() {...} Perfect! :-P
Nov 30 2007
parent reply Matti Niemenmaa <see_signature for.real.address> writes:
Bill Baxter wrote:
 Now you're on to something!  Just tweak that last one slightly:
 
   (this is !in function) int my_method() {...}
 
 Perfect!
Nah, this one's perfect: (this function is !in this class) int my_method() {...} -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Nov 30 2007
next sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Matti Niemenmaa wrote:
 Bill Baxter wrote:
 Now you're on to something!  Just tweak that last one slightly:

   (this is !in function) int my_method() {...}

 Perfect!
Nah, this one's perfect: (this function is !in this class) int my_method() {...}
If only we had Java's instanceof: (this function is !in this instanceof this class) int my_method() {...}
Nov 30 2007
prev sibling next sibling parent reply BCS <BCS pathlink.com> writes:
Matti Niemenmaa wrote:
 Bill Baxter wrote:
 
Now you're on to something!  Just tweak that last one slightly:

  (this is !in function) int my_method() {...}

Perfect!
Nah, this one's perfect: (this function is !in this class) int my_method() {...}
Free kudos* to the first person to get a haiku of key words to compile. Anyone want to go for a limerick? * kudos will consist of "well done ____" being posted where ____ is replaced with the name of the person awarded said kudos.
Nov 30 2007
next sibling parent Christopher Wright <dhasenan gmail.com> writes:
BCS wrote:
 Matti Niemenmaa wrote:
 Bill Baxter wrote:

 Now you're on to something!  Just tweak that last one slightly:

  (this is !in function) int my_method() {...}

 Perfect!
Nah, this one's perfect: (this function is !in this class) int my_method() {...}
Free kudos* to the first person to get a haiku of key words to compile. Anyone want to go for a limerick? * kudos will consist of "well done ____" being posted where ____ is replaced with the name of the person awarded said kudos.
Problem is, most keywords don't work too close to each other. If you allow arbitrary identifiers, too easy.
Nov 30 2007
prev sibling parent reply Matti Niemenmaa <see_signature for.real.address> writes:
BCS wrote:
 Free kudos* to the first person to get a haiku of key words to compile.
protected static this() { if (new short) assert (is( typeof(typeid(int)))); }
 Anyone want to go for a limerick?
static assert (is(typeof(new short))); static this() { if (new short is new short) volatile if (true) try { debug null; do {} while (false); } catch { return new ushort;}} Both compile with 1.024. With 2.0 one could probably use the const stuff to good effect. -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Dec 01 2007
next sibling parent BCS <ao pathlink.com> writes:
Reply to Matti,

 BCS wrote:
 
 Free kudos* to the first person to get a haiku of key words to
 compile.
 
protected static this() { if (new short) assert (is( typeof(typeid(int)))); }
 Anyone want to go for a limerick?
 
static assert (is(typeof(new short))); static this() { if (new short is new short) volatile if (true) try { debug null; do {} while (false); } catch { return new ushort;}} Both compile with 1.024. With 2.0 one could probably use the const stuff to good effect.
well done Matti!!! That is cool.
Dec 02 2007
prev sibling parent Sebastian Beschke <s.beschke gmx.de> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matti Niemenmaa schrieb:
 BCS wrote:
 Free kudos* to the first person to get a haiku of key words to compile.
protected static this() { if (new short) assert (is( typeof(typeid(int)))); }
 Anyone want to go for a limerick?
static assert (is(typeof(new short))); static this() { if (new short is new short) volatile if (true) try { debug null; do {} while (false); } catch { return new ushort;}} Both compile with 1.024. With 2.0 one could probably use the const stuff to good effect.
OMG. Well done Matti. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHU1VuKb/1n5A2TAMRAh/TAJ0bo2rJlbIQaaF8gE2hy225PonKYgCfSqpG VKD0g+HUK/VByPhzfL/n1i8= =z6N3 -----END PGP SIGNATURE-----
Dec 02 2007
prev sibling parent Leandro Lucarella <llucax gmail.com> writes:
Matti Niemenmaa, el 30 de noviembre a las 21:11 me escribiste:
 Bill Baxter wrote:
 Now you're on to something!  Just tweak that last one slightly:
 
   (this is !in function) int my_method() {...}
 
 Perfect!
Nah, this one's perfect: (this function is !in this class) int my_method() {...}
The obvious missing one is:
 (class function with out this) int my_method() {...}
-- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- Oiganmen ñatos de corazón, es más posible que un potus florezca en primavera a que un ángel pase con una remera. -- Peperino Pómoro
Nov 30 2007
prev sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
Matti Niemenmaa wrote:
 (this is !in this) int my_method() {...}
You get an oatmeal rasin cookie for that! And an easter egg in the Descent parser that won't mark that as a syntax error if I'm feeling bored.
Nov 30 2007
prev sibling parent reply Mike <vertex gmx.at> writes:
This reminds me of this:

http://forums.worsethanfailure.com/forums/thread/82701.aspx

Maybe we could try the same with D :)

BCS Wrote:

 Reply to Matti,
 
 BCS wrote:
 
 Free kudos* to the first person to get a haiku of key words to
 compile.
 
protected static this() { if (new short) assert (is( typeof(typeid(int)))); }
 Anyone want to go for a limerick?
 
static assert (is(typeof(new short))); static this() { if (new short is new short) volatile if (true) try { debug null; do {} while (false); } catch { return new ushort;}} Both compile with 1.024. With 2.0 one could probably use the const stuff to good effect.
well done Matti!!! That is cool.
Dec 02 2007
parent reply Matti Niemenmaa <see_signature for.real.address> writes:
Mike wrote:
 This reminds me of this:
 
 http://forums.worsethanfailure.com/forums/thread/82701.aspx
 
 Maybe we could try the same with D :)
class X { void f() /+ begin +/ in {} out {} body {} align abstract auto const debug deprecated export extern final package private protected public scope synchronized struct { static union {} } override invariant { asm{} try volatile with (typeof(super)) switch(typeid(char) is null) { goto default; case false: } catch { throw new class {}; } finally {} delete this; } unittest { for (;;) if (cast(bool)true) { do continue; while (function(){}); } else break; return assert(delegate void(lazy byte, ref cdouble, inout cfloat, creal, dchar, double, float, idouble, ifloat, ireal, long, real, ubyte, uint, ulong, ushort, wchar){}); } } alias int /+ end +/ x; 83 keywords of a possible 98 (unless I missed some). The code compiles with -unittest -debug. There's one warning "switch statement has no default" if compiled with -w, though, so I guess I only get 82 points according to the rules there. :-) The class is needed only to get the anonymous struct, otherwise it could be all at global scope. Keywords which can't be used at all: cent, ucent, macro The rest of the keywords need an identifier and thus can't be used without breaking the chain. Feel free to prove me wrong, of course. :-) I chose to use "alias" at the end there because it happened to be alphabetically the first. The other options: enum, import, interface, foreach, foreach_reverse, mixin, module pragma, template, typedef, version, __traits -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Dec 03 2007
parent reply Christopher Wright <dhasenan gmail.com> writes:
Matti Niemenmaa wrote:
 Mike wrote:
 This reminds me of this:

 http://forums.worsethanfailure.com/forums/thread/82701.aspx

 Maybe we could try the same with D :)
class X { void f() /+ begin +/ in {} out {} body {} align abstract auto const debug deprecated export extern final package private protected public scope synchronized struct { static union {} } override invariant { asm{} try volatile with (typeof(super)) switch(typeid(char) is null) { goto default; case false: } catch { throw new class {}; } finally {} delete this; } unittest { for (;;) if (cast(bool)true) { do continue; while (function(){}); } else break; return assert(delegate void(lazy byte, ref cdouble, inout cfloat, creal, dchar, double, float, idouble, ifloat, ireal, long, real, ubyte, uint, ulong, ushort, wchar){}); } } alias int /+ end +/ x; 83 keywords of a possible 98 (unless I missed some). The code compiles with -unittest -debug. There's one warning "switch statement has no default" if compiled with -w, though, so I guess I only get 82 points according to the rules there. :-) The class is needed only to get the anonymous struct, otherwise it could be all at global scope. Keywords which can't be used at all: cent, ucent, macro The rest of the keywords need an identifier and thus can't be used without breaking the chain. Feel free to prove me wrong, of course. :-) I chose to use "alias" at the end there because it happened to be alphabetically the first. The other options: enum, import, interface, foreach, foreach_reverse, mixin, module pragma, template, typedef, version, __traits
You could've done 'alias __traits(something...) identifier' instead, for one extra.
Dec 03 2007
next sibling parent Matti Niemenmaa <see_signature for.real.address> writes:
Christopher Wright wrote:
 You could've done 'alias __traits(something...) identifier' instead, for one
 extra.
TBH I didn't use __traits because I don't have a 2.0 compiler handy. I didn't know I could do that, cheers. :-) -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Dec 03 2007
prev sibling parent reply Christopher Wright <dhasenan gmail.com> writes:
Christopher Wright wrote:
 Matti Niemenmaa wrote:
 Mike wrote:
 This reminds me of this:

 http://forums.worsethanfailure.com/forums/thread/82701.aspx

 Maybe we could try the same with D :)
class X { void f() /+ begin +/ in {} out {} body {} align abstract auto const debug deprecated export extern final package private protected public scope synchronized struct { static union {} } override invariant { asm{} try volatile with (typeof(super)) switch(typeid(char) is null) { goto default; case false: } catch { throw new class {}; } finally {} delete this; } unittest { for (;;) if (cast(bool)true) { do continue; while (function(){}); } else break; return assert(delegate void(lazy byte, ref cdouble, inout cfloat, creal, dchar, double, float, idouble, ifloat, ireal, long, real, ubyte, uint, ulong, ushort, wchar){}); } } alias int /+ end +/ x; 83 keywords of a possible 98 (unless I missed some). The code compiles with -unittest -debug. There's one warning "switch statement has no default" if compiled with -w, though, so I guess I only get 82 points according to the rules there. :-) The class is needed only to get the anonymous struct, otherwise it could be all at global scope. Keywords which can't be used at all: cent, ucent, macro The rest of the keywords need an identifier and thus can't be used without breaking the chain. Feel free to prove me wrong, of course. :-) I chose to use "alias" at the end there because it happened to be alphabetically the first. The other options: enum, import, interface, foreach, foreach_reverse, mixin, module pragma, template, typedef, version, __traits
You could've done 'alias __traits(something...) identifier' instead, for one extra.
My mistake; that wouldn't actually increase it, if you're only counting globally reserved keywords. If you could have an anonymous template, you could do: mixin (template () { module foo; })!();
Dec 03 2007
parent Matti Niemenmaa <see_signature for.real.address> writes:
Christopher Wright wrote:
 Christopher Wright wrote:
 Matti Niemenmaa wrote:
<snip>
         return assert(delegate void(lazy byte, ref cdouble, inout
 cfloat, creal,
 dchar, double, float, idouble, ifloat, ireal, long, real, ubyte,
 uint, ulong,
 ushort, wchar){});
     }
 }
 alias int /+ end +/ x;
<snip>
 You could've done 'alias __traits(something...) identifier' instead,
 for  one extra.
My mistake; that wouldn't actually increase it, if you're only counting globally reserved keywords.
Sure it would. "int" can be moved into that delegate and then we'd have __traits in addition to everything I originally used.
 If you could have an anonymous template, you could do:
 mixin (template () { module foo; })!();
Yeah, anonymous templates would chop off a few keywords off the "left-over" list. I'm not sure if putting module in a template like that would work, though, but there are plenty of other options if it doesn't. -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
Dec 03 2007