J3/05-162 Date: 08 February 2005 To: J3 From: Thomas L. Clune Title: New intrinsics to determine current scope Basic Functionality: -------------------- Provide instrinsic routines which return information about the current lexical scope. Rationale: ---------- Logging and reporting of exceptional events can be significantly enhanced by providing means to determine the location of the event within the source code. Such intrinsics strongly compliment traditional ASSERT capabilities and enable development of general error handling utilities. Some of these intrinsics may also be of value in certain processes requiring registration (ala software frameworks). Example: ASSERT(...,msg=my_msg(PROCEDURE_NAME()),...) Estimated Impact: ----------------- Small impact for the standard and probably small impact for the compiler vendors. Might get tricky if a consensus on some arbitrary details cannot be arrived at. Detailed Specification: ----------------------- Provide the following new intrinsic procedures: * LINE_NUMBER() * SOURCE_NAME() * PROCEDURE_NAME() * MODULE_NAME() LINE_NUMBER() returns the line number within the source file at which the invoking statement begins. SOURCE_NAME() returns the name of the source file in which the intrisic has been invoked. If the file is from standard input, the result should be " " (or "STDIN"?). Result is compiler dependent. PROCEDURE_NAME() will return the qualified name of the procedure within which the intrinsic is invoked. For internal procedures, the result should consist of both the concatenation of the hosting procedure and the internal procedure names. Results are: [:] or [:] or [:] MODULE_NAME() will return the name, of the module in which the intrinsic is invoked or an empty string if not within any module. Results are: " " or or :