EProgrammerNotFound exception in Delphi?
Asked Answered
C

8

146

In Delphi 2009, SysUtils.pas contains this in line 425:

EProgrammerNotFound = class(Exception);
  • Is this simply an easter egg or something serious?
  • When should this exception be raised?
  • Does it also exist in Delphi Prism and/or Free Pascal?

Q: Is this exception class still declared in Delphi (currently XE7)? A: Yes, and it is even documented!

Nonstandard way to indicate software faults.

You can use EProgrammerNotFound as an alternative to indicate software faults detected at run time.

Cronin answered 18/1, 2010 at 5:49 Comment(3)
This exception recently has been mentioned in an answer about Androids UserManager.isUserAGoat() functionCronin
System.SysUtils.EProgrammerNotFound XE7Kentkenta
I think this design pattern deserves a formal name. I see it here also: YourCodeSucksExceptionInapproachable
S
166

It is just the result of a long day and we had gotten a little giddy. For many, many years (ever since I'd been on the team), we'd always joked about replacing some error message in the compiler for one of the most common errors with a similar message. Internally we've always joked and poked fun at different things and people (mostly on the team itself). If you don't have a sense of humor, you're destined to an early grave.

It was a simple conversation;

"Oh, you should have raised the EProgrammerNotFound exception in that function."
"LOL! We should add that exception and see who notices."
"I wonder how much speculation there will be about why it is there?"

So, I guess all I can say is, "You've all played right into our hands ;-)... Buwahahaha! pwned!"

Skin answered 18/1, 2010 at 19:37 Comment(4)
Isn't this the most common exception in Tron?Tributary
It is quite reasonable to have such an exception. I always regard this exception as ENotImplementedExceptionSeek
@stanleyxu2005, for that you can use the ENotImplemented exception.Beautify
I have a custom EProgrammerException. I was typing the code to complete EProgr... when code insight showed me EProgrammerNotFound. Sadly i cannot use EProgrammerNotFound, as my EProgrammerException descends from EInvisibleException; as it meant as a cross between an assertion failure and an EAbort exception (i caught a programmer screwing something up, and i'm going to stop here).Barfield
B
28

It is used in conjunction with the "fix-inline" technology which requires that the programmer has to be linked into the exe file ;-)

Bufford answered 18/1, 2010 at 7:47 Comment(0)
W
24

It was introduced in Delphi 2009, still present in Delphi 2010, and recently got some more attention on the internet.

I think it is an easter egg, similar to "EBCAK" (Error Between Chair and Keyboard), and the skipping of Delphi version number 13.

EProgrammerNotFound

  • is declared in the Win32 branch of the SysUtils unit, but not used anywhere in the RTL or VCL
  • is not present in Delphi Prism
  • was introduced in Delphi 2009, so not present in VCL.NET
  • has currently (version 3.5) nothing similar in the .NET framework (not sure why, these guys do have humour)

I don't think EProgrammerNotFound is actually meant to be used at all, but since it is there, people will jokingly use it (similar like putting a stray "const False = True; True = not False;" in someone elses sourcecode).

--jeroen

Wacke answered 18/1, 2010 at 8:39 Comment(3)
Hmm, programmer is not only a person, but also a device (for programming e.g. flash of embedded devices). Do I smell an IPhone here? Naah, then it would be in the IDE source, not sysutils.Headwork
EBCAK? I always heard it expressed as PEBKAC. (Problem Exists Between Keyboard And Chair).Omega
The stray const made me giggle :)Ragtime
T
12

The origin is debatable, but it's been known for a while...
Marco Cantu joked about it in a "Fun Side of Delphi" session.
IMO, it should be used more often ;-)

Read on:
http://wings-of-wind.com/2010/01/12/best-programming-feature-ever/
http://blog.barrkel.com/2008/11/reference-counted-pointers-revisited.html

PS: I don't think it exists in Delphi Prism, FreePascal or C# (but it should). <G>

Thin answered 18/1, 2010 at 6:24 Comment(0)
H
6

It's the runtime analog of the compiler's "Syntax error: Programer expected." ;>

Honeysweet answered 24/4, 2011 at 0:28 Comment(1)
You should have seen the build with the compiler strings localized to Jive!Honeysweet
G
5

It is a kind of self describing joke, you can try this code

raise EProgrammerNotFound.Create('Jack is away');

or

raise ENotImplemented.Create('May be in future this will work');

The above works in Delphi 10 Seattle.

Grindelia answered 29/11, 2017 at 10:46 Comment(0)
C
3

With programmer, it is not the programmer that is sitting behind Delphi that is referenced. I think it is used for the fact that in D2009 and above they planned (never used it don't know if it works) that every object was waitable.

Carduaceous answered 18/1, 2010 at 6:35 Comment(2)
Actually, it is usable. You can pass any object to TMonitor.Enter and TMonitor.Exit. And i'm not sure if it's an easter egg or not...Cone
What does an object being waitable have to do with programmers or whether they're found? And what programmer is being referenced?Palocz
V
0

I am a programmer, am I an exception than ?

Marco Cantù also describes this in his book 'Delphi 2009 handbook' - page 242. He tells it's never jused in the VCL source code.

Vibration answered 18/1, 2010 at 8:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.