Search found 13 matches

by dram
Mon Feb 27, 2017 11:38 am
Forum: Help
Topic: About file path auto expansion in several library(os) predicates
Replies: 4
Views: 852

Re: About file path auto expansion in several library(os) predicates

I see your point now, it's really a pity that such many Prolog implementations do path expansion.

I'll get used to it.

Thanks for your patience!
by dram
Mon Feb 27, 2017 2:04 am
Forum: Help
Topic: About file path auto expansion in several library(os) predicates
Replies: 4
Views: 852

Re: About file path auto expansion in several library(os) predicates

If we take security into consideration, auto expansion is a bit vulnerable, similar to command injection[1], although not that serious. Let me elaborate an example. If I use Logtalk to create a web application, using filesystem to store user data, one directory per user. If I naively use user name a...
by dram
Sun Feb 26, 2017 10:38 am
Forum: Help
Topic: About file path auto expansion in several library(os) predicates
Replies: 4
Views: 852

About file path auto expansion in several library(os) predicates

I found that there are several predicates in library(os) do file path expansion automatically (e.g. make_directory/1, delete_directory/1), which make me a bit surprised, for following reasons: 1. It is a bit uncommon, I can not immediately thought out some other languages which do the same. 2. It wi...
by dram
Sun Feb 26, 2017 2:53 am
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

Re: How to initialize seed for library(random)?

Ah, I see, return type of os::time_stamp/1 has been changed in 3.09.3.
by dram
Sun Feb 26, 2017 1:59 am
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

Re: How to initialize seed for library(random)?

Just found that there is `os::time_stamp/1` in Logtalk, so code can be fully portable:

Code: Select all

os::time_stamp(Time),
Seconds is truncate(Time),
random::randomize(Seconds)
by dram
Sun Feb 26, 2017 1:51 am
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

Re: How to initialize seed for library(random)?

Reasonable.

Now, with the newly added `randomize/1`, I use following code in SWI-Prolog:

Code: Select all

get_time(Time),
Seconds is truncate(Time),
random::randomize(Seconds)
by dram
Sat Feb 25, 2017 12:30 pm
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

Re: How to initialize seed for library(random)?

Wow! What a quick fix. Personally, I do not quite like the name `frandom`, for following reasons: 1. I really appreciate the naming conversion in Logtalk code that abbreviations are used very sparsely, so I think `fast_random` is better, although not quite good (see below). 2. `frandom` may be confu...
by dram
Sat Feb 25, 2017 11:53 am
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

Re: How to initialize seed for library(random)?

Yes, that will work for me. Following are some random thoughts: 1. If we add `randomize/1`, a predicate to get current time in seconds is also needed, AFAIK currently there is no such thing in library(time). 2, Or we can add something like `randomize/0` in GProlog[1], which use time as seed internal...
by dram
Sat Feb 25, 2017 8:09 am
Forum: Help
Topic: How to initialize seed for library(random)?
Replies: 9
Views: 775

How to initialize seed for library(random)?

After reading through documents of library(random), I failed to find a way to properly initialize the random seed. Currently, I use following code after peeking into the source of random.lgt, not sure if it is correct: time::now(H, M, S), random::set_seed(seed(H, M, S)) But argument of `set_seed` is...
by dram
Tue Feb 21, 2017 10:09 am
Forum: Help
Topic: Undefined predicate in Learn Logtalk in Y Minutes
Replies: 2
Views: 402

Re: Undefined predicate in Learn Logtalk in Y Minutes

I think I have found the problem:

Code: Select all

:- public(bar).
should be

Code: Select all

:- public(bar/0).
Is that the point?
by dram
Tue Feb 21, 2017 9:19 am
Forum: Help
Topic: Undefined predicate in Learn Logtalk in Y Minutes
Replies: 2
Views: 402

Undefined predicate in Learn Logtalk in Y Minutes

In Learn Logtalk in Y Minutes, there is an example for undefined predicate, which load successfully according to the tutorial content. But I failed to load in swilgt (SWI 7.3.35 and Logtalk 3.9.3-rc1). Following are detailed error message: 1 ?- {foo}. ! Type error: expected predicate_indicator but g...
by dram
Mon Feb 20, 2017 5:15 am
Forum: Wish list
Topic: Order of contents in User Manual
Replies: 3
Views: 856

Re: Order of contents in User Manual

Thanks for your suggestions, I'll go through "Learn X in Y minutes" tutorial and examples in the distribution.

BTW, is there any TODO list or roadmap around? I have checked both at Logtalk website and github repo, but failed to find one. It will help convey the direction of Logtalk's development.
by dram
Fri Feb 17, 2017 1:30 am
Forum: Wish list
Topic: Order of contents in User Manual
Replies: 3
Views: 856

Order of contents in User Manual

Hi all, I'm a newbie to Logtalk, when first looking into Logtalk, I really appreciate the richness of Logtalk's documents, thanks for your hard work! Here is a simple suggestion, related to contents order of User Manual. I kind of think that it would be better to move "Installing Logtalk" and "Writi...