Questions tagged [logtalk]

Logtalk is an object-oriented logic programming language based on Prolog

Logtalk is an object-oriented logic programming languages based on Prolog.

27 questions
6
votes
3 answers

Colliding stellar objects via multimethods in OO Prolog?

I wonder how one would combine unification and OO in Prolog. I would like to implement a multimethod dispatch on term objects. Without term objects and simple terms I would do the following and could profit from multi-argument…
user502187
3
votes
1 answer

Logtalk and XPCE

Can an application be developed using both XPCE and Logtalk, or are the class systems incompatible in some way?
adamo
  • 3,584
  • 1
  • 18
  • 23
3
votes
1 answer

Term-expansion workflows

I'm adding library support for common term-expansion workflows (1). Currently, I have defined a "set" workflow, where sets of term-expansion rules (2) are tried until one of them succeeds, and a "pipeline" workflow, where expansion results from a…
Paulo Moura
  • 18,373
  • 3
  • 23
  • 33
3
votes
2 answers

Logtalk : what is the best way to run all test suites?

In Logtalk code examples, each example provides its own test suite which is runnable in a "standalone" mode (one test suite at once). But, as the title says, I'm interested in the best approaches of testing all test suites (all loaded objects…
Koryonik
  • 2,728
  • 3
  • 22
  • 27
2
votes
1 answer

Logtalk: meta::map, lambda expression and access to private method

I think this is a scope related problem. If I have a rule on my object like this: :- public(new/2). :- mode(new(+list, -object_identifier), one). new(Args, Instance) :- self(Self), create_object(Instance, [instantiates(Self)], [], []), …
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
2
votes
1 answer

Objectifying Array based on Term

I have this for array : ary1d_new(Size,Sym,ArySym,Ary) :- functor(Ary,ArySym,Size), forall(arg(X,Ary,_), nb_setarg(X,Ary,Sym)). ary1d_get(Pos,Ary,Val) :- arg(Pos,Ary,Val). ary1d_set(Pos,Ary,Val) :- nb_setarg(Pos,Ary,Val). trying to turn…
sten
  • 7,028
  • 9
  • 41
  • 63
2
votes
1 answer

Late binding a variable?

I have logtalk rule to add to the prolog DB : add(IF, THEN) :- new_uid(U), assertz(cond(IF, 0, U)), assertz(act(U) :- THEN). it seems to work ok.. i.e. it splits the rule to TWO separate facts (which later I interpret). ?-…
sten
  • 7,028
  • 9
  • 41
  • 63
2
votes
1 answer

swi prolog 8.0.2 : gziped http

I tried to make work a piece of code that opens an http connection. Nevertheless, web page may transfered as plain text or gziped. As a result, the code with pragmatism tries to open as plain text and if it fails and receives an exception, tries as…
2
votes
0 answers

Behavior of `foldl1/3` and `foldr1/3` meta-predicates on empty lists

Looking for advice. I'm adding foldl1/3 and foldr1/3 meta-predicates to the Logtalk library. These can be easily defined: foldl1(Closure, [Head| Tail], Result) :- foldl(Closure, Head, Tail, Result). foldr1(Closure, [Head| Tail], Result) :- …
Paulo Moura
  • 18,373
  • 3
  • 23
  • 33
2
votes
3 answers

Logtalk method calls performance optimization

While playing with Logtalk, is seems my program was longer to execute with Logtalk object versus plain Prolog. I did a benchmark comparing the execution of the simple predicate in plain Prolog with the logtalk object encapsulation equivalent below…
Koryonik
  • 2,728
  • 3
  • 22
  • 27
2
votes
1 answer

Accessing SWI-Prolog libraries from Logtalk

I'm having a lot of fun using Logtalk, but ran into an issue using phrase_from_file. Specifically, my case looks something like this: :- object(scan_parser). :- public(scanlist//1). scanlist([Scan|Scans]) --> scan(Scan), dcg_basics:blanks,…
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
1
vote
1 answer

Category method provided by the object

Let say I have : :- category(multi). :- public([set/2, set/3]). %% set(r,c,v). set([],_). %% multi-ix/value set set([[Row, Col]|RCs], Value) :- \+ is_list(Value), set(Row, Col, Value), set(RCs, Value). set([[Row, Col]|RCs],…
sten
  • 7,028
  • 9
  • 41
  • 63
1
vote
1 answer

Accessing Parametric object from category

how to Access Parametric object from a ategory :- category(attributes). :- public(info/1). info(Value) :- arg(1,_Array_,Value). :- end_category. :- object(array(_Array_),imports([attributes])). this does not work ... * Singleton…
sten
  • 7,028
  • 9
  • 41
  • 63
1
vote
1 answer

Extending and/or parametric object as attribute

As I understand now from Array as object I have to use parametric object, because using non-parametric Logtalk objects implies that I have to use assert i.e. any change/set rewrites the whole array. The problem is then : how do you EXTEND the Array…
sten
  • 7,028
  • 9
  • 41
  • 63
1
vote
1 answer

Number of objects in Logtalk

I've got the protocol: :- protocol(person). :- public([name/1, age/1]). :- end_protocol. For example, I've made unknown number of objects by using create_object/4, how can I get a number of them? It is not a problem to get their names by…
1
2