SWI-Prolog / packages-sgml

The SWI-Prolog SGML/XML/HTML parser
4 stars 10 forks source link

accept a free var as specifier, instantiating to index of DOM element #6

Closed CapelliC closed 8 years ago

CapelliC commented 8 years ago

previous behaviour always (?) instantiated a free var to 'last', now it binds to the index of DOM element, allowing to express easily the relative position of siblings

triska commented 8 years ago

Awesome improvement, thank you Carlo! @JanWielemaker, could you please have a look and merge this if applicable? Thank you!

JanWielemaker commented 8 years ago

Thanks. I somehow missed this pull request. Having an index one can ask for is certainly useful. I wonder however whether we should change this into index(?Index), where Index can be one of Integer, Var, last or Last-Expr? Just a variable as part of this already dangerously ambiguous specification smells a bit dangerous (notably unintended uninstantiated arguments resulting in silent binding to an index).

In that case the plain old Integer, last and last-Expr become aliases for index(...).

triska commented 8 years ago

Yes, definitely the selector index(?Index) would be a good improvement! All things that are implicitly committed to are very ambiguous, and the wider their scope the worse it is.

Pure representations FOR THE WIN!

JanWielemaker commented 8 years ago

Ok. Merged and added index(?Index).

triska commented 8 years ago

Great, thank you! I have added some documentation improvements for this to #9.