Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.
Can anyone explain the difference between the predicates (or notation) toBinary(Term) = Binary and ::toBinary(Term) = Binary.
-
- VIP Member
- Posts: 341
- Joined: 14 Nov 2002 0:01
Re: Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.
The Language Reference teaches:
The example outputs:
An example to demonstrate the disambiguation of built-in predicate toBinary from a user-defined predicate with same name:Visual Prolog contains an embedded hidden class, which provides declarations and implementations to all built-in constants, domains, and predicates.
...
Each compilation unit implicitly contains the declaration of this embedded hidden class. To disambiguate from other entities with the same name you can use "::" before names of built-in items.
Code: Select all
class predicates
toBinary : (Term) -> binary Ones.
clauses
toBinary(_) = $[01, 01, 01, 01].
constants
zero : integer = 0.
clauses
run() :-
BuiltIn = ::toBinary(zero),
UserDefined = toBinary(zero),
stdIo::write(BuiltIn, '\n'),
stdIo::write(UserDefined, '\n').
Code: Select all
$[00,00,00,00]
$[01,01,01,01]
Regards Martin
Re: Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.
Thank you very much Martin.