Page 1 of 1

Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.

Posted: 12 Apr 2024 5:28
by Faddey
Can anyone explain the difference between the predicates (or notation) toBinary(Term) = Binary and ::toBinary(Term) = Binary.

Re: Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.

Posted: 13 Apr 2024 22:05
by Martin Meyer
The Language Reference teaches:
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.
An example to demonstrate the disambiguation of built-in predicate toBinary from a user-defined predicate with same name:

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').
The example outputs:

Code: Select all

$[00,00,00,00] $[01,01,01,01]

Re: Notation toBinary(Term) = Binary and ::toBinary(Term) = Binary.

Posted: 15 Apr 2024 5:39
by Faddey
Thank you very much Martin.