ID:116036
 
Basically, I took the method described here, and turned it into a library which can be found here. Obviously the original idea was not mine.

For those who don't want to read the external links, basically..
This library lets you create a new /restricted datum, give it a minimum, maximum, and a current, and then you use the procs provided to change the number, or get information about the number. If you try to change the number out of it's bounds, it will stop at that bound (setting it greater than max will put it at max).

This has some pretty nice benefits for inheritance too. If you make a hp stat, for example, and you have some bars on-screen, you can just override set_current() to change the bar too. An example of what I mean can be seen here.

Overall, I'd say it's pretty neat.
Neat idea.

Actually, I'd say the example you gave for inheritance is not the best. It's better to have the health bar be represented by an object from a suite of HUD-objects, perhaps as so:

interface/hud/bar/health
Update(h)
var/current_health = h ? h : player.getHealth()
..(current_health) // draw!
It may not be the best example, but it's one of the only ones I could come up with, since that's mostly what I used it for. It can be better done, yeah, I agree.
I do something similar in all my projects, lolz.
If you're doing this in your game, actually, I recommend rewriting it as soon as possible, to avoid getting bogged down by it in the future. Basically you want the HUD and the actual attributes to be completely separate features, tied together by the mob itself.

mob/player
var/restricted_number/health
proc/getHealth()
return health.get_current()
proc/setHealth(n)
health.set_current(n)
src.HUD.health.Update()