View mode: basic / threaded / horizontal-split · Log in · Help
December 02, 2007
Re: Idea for getting rid of "static" on methods
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.
> 
>
December 03, 2007
Re: Idea for getting rid of "static" on methods
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
December 03, 2007
Re: Idea for getting rid of "static" on methods
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.
December 03, 2007
Re: Idea for getting rid of "static" on methods
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
December 03, 2007
Re: Idea for getting rid of "static" on methods
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; })!();
December 03, 2007
Re: Idea for getting rid of "static" on methods
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
Top | Discussion index | About this forum | D home