This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

feature idea: type-only convenience variables


(gdb) whatis foo
type = long::and::cumbersome
(gdb) p *(long::and::cumbersome *) $27

Now how about:

(gdb) p typeof(foo)
$92 = (long::and::cumbersome) <no value>
(gdb) p *(typeof($92) *) $27
(gdb) p &$92 + 1
Expression '$92' has only type and no value.
(gdb) ptype $92
type = long::and::cumbersome
(gdb) b typeof(foo)::method
(gdb) b template.hh:27 if arg==3 && typeof(*this)==typeof($92)
(gdb) b template.hh:98 if arg==57 && typeof(*this) >= typeof($92)

The comparison of types is extra gravy and I have no clue about actual good
syntax for it.  What's key first is using typeof(expr) anywhere you can use
types both in expressions and in "typeof(...)::scoped::name" resolution.

Two notes intended there about the type comparisons (last two "b" lines):
1. First example is exact match, >= is intended as "is a" inheritance relation.
2. For extra bonus points, notice at bkpt resolution/setup when the type
   comparison part of the cond expr is known statically at each individual
   site of a multi-location.  It might be guaranteed true by the locally
   instantiated types' inherent relationships, or it might be you are
   testing for a vtbl typeid match on the particular value to resolve
   typeof.  Or perhaps that dynamic use should be called out explicitly
   using a C++ "typeid" expression.

This sort of seems naturalish to me.  But it occurs to me that it overlaps
largely with the "type nicknames" feature I'm also suggesting, and perhaps
just that could serve the non-comparison cases fine with a different
approach to syntax (though nicknames aren't usable in the "anonymous"
fashion of "p *(typeof(expr)) ptr", which seems like a nice convenience).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]