www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Fun: Shooting yourself in the foot in D

reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
   http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

Some entries for reference:

C
- You shoot yourself in the foot.
- You shoot yourself in the foot and then nobody else can figure out 
what you did.

C++
- You accidentally create a dozen instances of yourself and shoot them 
all in the foot. Providing emergency medical assistance is impossible 
since you can't tell which are bitwise copies and which are just 
pointing at others and saying, "That's me, over there."

Python
- You shoot yourself in the foot and then brag for hours about how much 
more elegantly you did it than if you had been using C or (God forbid) 
Perl.

What would the entry for D be? :)

Ali
Oct 27 2016
next sibling parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 10/27/16 3:49 PM, Ali Çehreli wrote:
   http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can figure out
 what you did.

 C++
 - You accidentally create a dozen instances of yourself and shoot them
 all in the foot. Providing emergency medical assistance is impossible
 since you can't tell which are bitwise copies and which are just
 pointing at others and saying, "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about how much
 more elegantly you did it than if you had been using C or (God forbid)
 Perl.

 What would the entry for D be? :)
You create a large meta-template library called footMassage, which then ends up via compiler inference compiling into a gun instead. -Steve
Oct 27 2016
next sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 10/27/2016 12:59 PM, Steven Schveighoffer wrote:

 You create a large meta-template library called footMassage, which then
 ends up via compiler inference compiling into a gun instead.
The first thing that came to my mind was a template-generated gun as well. :) Ali
Oct 27 2016
prev sibling next sibling parent cym13 <cpicard openmailbox.org> writes:
On Thursday, 27 October 2016 at 19:59:09 UTC, Steven 
Schveighoffer wrote:
 On 10/27/16 3:49 PM, Ali Çehreli wrote:
 [...]
You create a large meta-template library called footMassage, which then ends up via compiler inference compiling into a gun instead. -Steve
Then the GC kicks in and triggers it.
Oct 27 2016
prev sibling next sibling parent Guillaume Boucher <guillaume.boucher.d gmail.com> writes:
On Thursday, 27 October 2016 at 19:59:09 UTC, Steven 
Schveighoffer wrote:
 You create a large meta-template library called footMassage, 
 which then ends up via compiler inference compiling into a gun 
 instead.
Accidentally compiling a massage into a gun is not a high priority bug. In order to become the safest language available, we should concentrate our effort implementing a nitrogen oxide detector (which handles all non-pathological examples of smoke).
Oct 27 2016
prev sibling parent Stefan Koch <uplink.coder googlemail.com> writes:
On Thursday, 27 October 2016 at 19:59:09 UTC, Steven 
Schveighoffer wrote:
 On 10/27/16 3:49 PM, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out
 what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them
 all in the foot. Providing emergency medical assistance is 
 impossible
 since you can't tell which are bitwise copies and which are 
 just
 pointing at others and saying, "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much
 more elegantly you did it than if you had been using C or (God 
 forbid)
 Perl.

 What would the entry for D be? :)
You create a large meta-template library called footMassage, which then ends up via compiler inference compiling into a gun instead. -Steve
You would never shoot youtself in the foot. after 5 minutes the compiler dies with an OOM.
Oct 27 2016
prev sibling next sibling parent A D dev <addev dlang.com> writes:
On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them all in the foot. Providing emergency medical 
 assistance is impossible since you can't tell which are bitwise 
 copies and which are just pointing at others and saying, 
 "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much more elegantly you did it than if you had been using C 
 or (God forbid) Perl.

 What would the entry for D be? :)

 Ali
1) You pre-shoot the bullet while the gun is being made - for efficiency (CTFE). As a result, it misses the foot, which has not grown yet. 2) From that link: http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html this one is good: Concurrent Euclid: You shoot yourself in somebody else's foot.
Oct 27 2016
prev sibling next sibling parent reply Idan Arye <GenericNPC gmail.com> writes:
On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them all in the foot. Providing emergency medical 
 assistance is impossible since you can't tell which are bitwise 
 copies and which are just pointing at others and saying, 
 "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much more elegantly you did it than if you had been using C 
 or (God forbid) Perl.

 What would the entry for D be? :)

 Ali
You conceive a baby which is born with a bullet genetically shot in the foot
Oct 27 2016
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 10/27/2016 03:07 PM, Idan Arye wrote:
 On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html
 You conceive a baby which is born with a bullet genetically shot in the
 foot
Like others, this one is very nice! Especially interesting to note that genetic and generative have the same root. :) Ali
Oct 27 2016
prev sibling next sibling parent reply Temtaime <temtaime gmail.com> writes:
On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them all in the foot. Providing emergency medical 
 assistance is impossible since you can't tell which are bitwise 
 copies and which are just pointing at others and saying, 
 "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much more elegantly you did it than if you had been using C 
 or (God forbid) Perl.

 What would the entry for D be? :)

 Ali
You create some complicated template function and then compiler show you an ICE.
Oct 27 2016
parent reply Kirill Kryukov <kkryukov gmail.com> writes:
On Thursday, 27 October 2016 at 22:24:57 UTC, Temtaime wrote:
 On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
 [...]
You create some complicated template function and then compiler show you an ICE.
You shoot yourself in a tuple containing your foot, boot and sock.
Oct 27 2016
parent reply Chris <wendlec tcd.ie> writes:
On Friday, 28 October 2016 at 01:25:55 UTC, Kirill Kryukov wrote:

 You shoot yourself in a tuple containing your foot, boot and 
 sock.
Cannot implicitly convert expression (map(shoot(foot))) of type MapResult to std.ouch.InputRange!limb
Oct 28 2016
parent reply Patric Dexheimer <patric.dexheimer gmail.com> writes:
On Friday, 28 October 2016 at 09:29:41 UTC, Chris wrote:
 On Friday, 28 October 2016 at 01:25:55 UTC, Kirill Kryukov 
 wrote:

 You shoot yourself in a tuple containing your foot, boot and 
 sock.
Cannot implicitly convert expression (map(shoot(foot))) of type MapResult to std.ouch.InputRange!limb
You create the bullet in your foot for efficiency (CTFE).
Oct 28 2016
parent Chris <wendlec tcd.ie> writes:
On Friday, 28 October 2016 at 09:55:34 UTC, Patric Dexheimer 
wrote:
 On Friday, 28 October 2016 at 09:29:41 UTC, Chris wrote:
 On Friday, 28 October 2016 at 01:25:55 UTC, Kirill Kryukov 
 wrote:

 You shoot yourself in a tuple containing your foot, boot and 
 sock.
Cannot implicitly convert expression (map(shoot(foot))) of type MapResult to std.ouch.InputRange!limb
You create the bullet in your foot for efficiency (CTFE).
You shoot yourself in the foot, but it doesn't matter, it was allocated on the stack.
Oct 28 2016
prev sibling next sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them all in the foot. Providing emergency medical 
 assistance is impossible since you can't tell which are bitwise 
 copies and which are just pointing at others and saying, 
 "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much more elegantly you did it than if you had been using C 
 or (God forbid) Perl.

 What would the entry for D be? :)

 Ali
When you try shooting at your foot with your AK-47, you realize the GC has blown it already.
Oct 28 2016
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 10/28/2016 04:32 AM, Guillaume Piolat wrote:

 When you try shooting at your foot with your AK-47, you realize the GC
 has blown it already.
Or... the bullet stops midair, waiting for the GC to finish a collection cycle (probably for a lollipop created in another thread). Ali
Oct 28 2016
prev sibling next sibling parent reply John Colvin <john.loughran.colvin gmail.com> writes:
On Thursday, 27 October 2016 at 19:49:16 UTC, Ali Çehreli wrote:
   
 http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html

 Some entries for reference:

 C
 - You shoot yourself in the foot.
 - You shoot yourself in the foot and then nobody else can 
 figure out what you did.

 C++
 - You accidentally create a dozen instances of yourself and 
 shoot them all in the foot. Providing emergency medical 
 assistance is impossible since you can't tell which are bitwise 
 copies and which are just pointing at others and saying, 
 "That's me, over there."

 Python
 - You shoot yourself in the foot and then brag for hours about 
 how much more elegantly you did it than if you had been using C 
 or (God forbid) Perl.

 What would the entry for D be? :)

 Ali
You unregister your feet from the runtime in order to move smoothly, wander in front of a bullet that's paused by the GC, which then un-pauses and hits you in the foot.
Oct 28 2016
next sibling parent Dominikus Dittes Scherkl <Dominikus.Scherkl continental-corporation.com> writes:
On Friday, 28 October 2016 at 11:41:11 UTC, John Colvin wrote:
 You unregister your feet from the runtime in order to move 
 smoothly, wander in front of a bullet that's paused by the GC, 
 which then un-pauses and hits you in the foot.
This is the best one so far! This is typical D: circumvent safety to enable you to shoot yourself in the foot.
Oct 28 2016
prev sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 10/28/2016 04:41 AM, John Colvin wrote:

 a bullet that's paused by the GC
Wow. I've just said almost the same thing before reading this one. :) Ali
Oct 28 2016
prev sibling parent reply captaindet <2krnk gmx.net> writes:
as i just happened to have me mutilated, i couldn't resist (even though 
the example 'works' only with DMD-m64 bullets):


being forced to share your foot among parallel universes, it will surely 
find a stray bullet in one of them.


can you guess which toe is going to be blown off?

'''
version(DigitalMars)version(D_LP64){
	import std.stdio	: writeln;
	import core.atomic	: atomicOp;

	ulong toe0 = 2;
	shared ulong toe1 = 2;
	shared ulong toe2 = 2;
	shared ulong toe3 = 2;
	uint bullet1 = 1;
	int bullet2 = 1;
	ulong bullet3 = 1;

	toe0 -= 1;
	writeln( "toe0: ", toe0 );

	atomicOp!"-="( toe1, bullet1 );
	writeln( "toe1: ", toe1 );
	
	atomicOp!"-="( toe2, bullet2 );
	writeln( "toe2: ", toe2 );

	atomicOp!"-="( toe3, bullet3 );
	writeln( "toe3: ", toe3 );
}


( https://issues.dlang.org/show_bug.cgi?id=16651 )
Oct 30 2016
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 10/30/2016 04:41 PM, captaindet wrote:

     ulong toe0 = 2;
     shared ulong toe1 = 2;
     shared ulong toe2 = 2;
     shared ulong toe3 = 2;
Those toes are toolong and one is already missing. Make sure that the -boundscheck compiler flag is set. :o) Ali
Oct 30 2016