ASH symbol names are case-insensitive. I guess I knew this, but it still confuses me, on occasion. You can end up redefining things without knowing you are doing so.
yields
When juxtaposed like that, you can see it. But what about this one?
yields
That had me staring and going "Huh?" for a long time before I figured it out.
You are allowed to redefine symbols originally defined in an outer scope. Java does not allow that, but ASH does. I wonder why we decided that?
And in this case, we are redefining a slot variable with an item variable.
When we look for function redefinitions, it's similarly all based on parameter lists, not return value.
I'm not sure what change I am proposing - if any - but since that second example confused even me, would could be done to clarify things?
What scripts would break if nested redefinitions were not allowed?
What scripts would break if symbols were case-sensitive?
Code:
static slot OFFHAND = $slot[ off-hand ];
item offhand = equipped_item( OFFHAND );
equip( OFFHAND, $item[ none ] );
Code:
[color=red]Variable offhand is already defined (redef.ash, line 2)[/color]
Code:
static slot OFFHAND = $slot[ off-hand ];
{
item offhand = equipped_item( OFFHAND );
equip( OFFHAND, $item[ none ] );
}
Code:
[color=red]Function 'equip( item, item )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (redef.ash, line 4)[/color]
You are allowed to redefine symbols originally defined in an outer scope. Java does not allow that, but ASH does. I wonder why we decided that?
And in this case, we are redefining a slot variable with an item variable.
When we look for function redefinitions, it's similarly all based on parameter lists, not return value.
I'm not sure what change I am proposing - if any - but since that second example confused even me, would could be done to clarify things?
What scripts would break if nested redefinitions were not allowed?
What scripts would break if symbols were case-sensitive?