Re: [Factor-talk] Linter for Factor USING: ... ; forms

2018-02-07 Thread Björn Lindqvist
Hi guys,

I haven't tested it but it looks pretty good! But note that FUEL has a very
similar feature. You press C-c C-eu and it finds a minimal using list,
using restarts. So to make a free-standing one (which would be useful
because then non-emacs users can use it), you probably want to look in
fuel-debug-uses.el and fuel.factor for inspiration.

2018-02-07 10:44 GMT+01:00 CW Alston <cwalsto...@gmail.com>:

> Hi again - Posted a cleaned-up, working gist of a USING linter
> <https://gist.github.com/cwalston/f6da9cca0105f5d67483935380001d84>.
> See what you think of it.
> Cheers,
> ~cw
>
> P.S. - cat, I didn't notice your comments until I posted this. I'll take a
> good look
> at your suggestions. Thanks!
> ~cw
> --
> *~ Memento Amori*
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>


-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Secure Memory

2018-01-19 Thread Björn Lindqvist
Yes, there is (byte-array) which allocates uninitialized memory. User code
is not supposed to call that word. But there are many other ways to get
hold of memory you don't own. For example, you can just read it:

1234  0 alien-cell

That would attempt to read 4 or 8 bytes from address 1234. It will produce
a memory protection fault because the process doesn't own the address at
1234, but it would have worked fine if it did. It is as doug says, if you
can read it after the gc has run you can read it before too. Try running:

"it works" kernel.private:context vm:context memory>struct datastack>>
 0 alien-cell alien-address 0xf unmask 32 + 
alien>native-string

2018-01-17 23:11 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:

> Doug and Björn, I'd like to point out the following use case for your
> consideration, and then you can tell me if the selective zeroing of
> sensitive memory buffers by the GC makes sense.
>
> Some sensitive data is stored in a networked application (let's say, a Web
> Server with its security certificates).
> The data in the application is surrounded with some `with-destructors`
> combinators that will clear it when it's no longer needed.
> But - the GC comes along and relocates the sensitive data in memory by
> copying it and not erasing it in the old place. The old location is marked
> as free memory.
>
> Now I assume that there is a way in Factor to allocate a `byte-array`
> without initializing the memory. This means that by requesting enough
> "free" memory from the runtime we will at some point get a hold of the
> block containing the released copy of the sensitive data.
>
> This is a problem, especially if our application is downloading and
> running scripts from the network, like, say, a Web Browser would do all the
> time.
>
> That combination of not clearing the memory on release and not clearing
> the memory on allocation (both expensive things to do if you do them all
> the time) creates the potential for the leakage.
>
> Adding a single bit flag that would tell GC to zero a particular object's
> memory on release (or reallocation) would be a great security feature, I
> think. Not a global command-line argument, but a per-object-instance flag.
>
> What do you think? Does it make sense? Is it difficult to implement?
>
> As to the Java finalizers argument - I'm not suggesting to rely on GC for
> the cleanup, as indeed it may never happen. I'd only want it not to leave
> old copies of some specific buffers hanging around when it's done its
> invisible (to the application code) magic.
>
> 17.01.2018, 22:40, "Doug Coleman" <doug.cole...@gmail.com>:
>
> We actually had a command-line argument to the vm to optionally zero the
> gc after collection but we removed the feature somewhere around when we
> dropped BSD support. It's probably better than nothing but if they could
> read your memory after a gc why not just read it before gc instead?
>
> Doug
>
> On Wed, Jan 17, 2018 at 1:34 PM Björn Lindqvist <bjou...@gmail.com> wrote:
>
> Factor when run in debug mode actually clears memory. See
> bump_allocator.hpp. Unfortunately clearing memory is slow as hell. The time
> complexity of copying gc is proportional to the number of surviving
> objects. But if you want to clear memory too it becomes proportional to the
> total number of allocated objects.
>
> Plus, relying on the gc to zero out sensitive memory is a bad idea. You
> never know when the gc runs or if it runs at all. That's why it is
> considered bad practice in Java to use finalizers. I think it would be
> better to use the destructors vocab to implement zeroing out of sensitive
> memory.
>
>
> 2018-01-16 23:17 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
>
> Hello!
>
>   I was reading a manual on the `8th` language, and noticed an interesting
> feature.
>   Apparently, it's possible to call a word on a memory buffer and thereby
> mark it as "sensitive information".
>   GC would zero the memory upon release.
>
>   Zeroing every bit of memory on release would add a lot of overhead (as I
> understand), but selectively clearing it like this could help with security
> applications that deal with certificates and passwords and stuff. This is
> especially useful, because in Factor GC can relocate (= copy) objects in
> memory. Does it clean up the memory it copied?
>
>   Do we have such a feature? Is it difficult to implement?
>   Bjourne, you've seen a lot of the runtime, can you comment?
>
> ---=---
>  Александр
>
> 
> --
> Check out th

Re: [Factor-talk] Disassembly

2018-01-19 Thread Björn Lindqvist
Hi Alex,

In this case, the new optimizer actually is strictly better. Mostly because
it uses shorter instruction encodings. For example, it uses inc rbx whereas
old factor used add rbx, 1. But the old factor had a compiler pass called
"height normalization" which in some situations made it emit superior code.
But it also sometimes generated faulty code so it had to be removed. :) I
have been working on a new step to get rid of redundant height changes but
it is not done. See https://github.com/factor/factor/issues/1617

2018-01-17 23:17 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:

> Hello, Björn!
>
> Thanks for the explanation! I've already lost hope of seeing a reply to
> that, but you appeared out of nowhere and saved the day. Thank you!
>
> Are you saying there was a different (better?) optimizer in the previous
> Factor releases? What happened to it?
>
> 17.01.2018, 22:25, "Björn Lindqvist" <bjou...@gmail.com>:
>
>
> r14 contains the datastack top pointer. It is incremented by 0x10 which is
> 16 bytes or 2 cells. Your code was supposed to put two items on the stack,
> but then the optimizer did a great job and noticed that the values didn't
> have to be put on the stack but could be kept in registers. But it didn't
> optimize away the stack increment/decrement. Possibly, the optimizer in
> 0.96 or 0.97 did a better job at optimizing code like that.
>
>
>
> ---=---
> Александр
>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>


-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Secure Memory

2018-01-17 Thread Björn Lindqvist
Factor when run in debug mode actually clears memory. See
bump_allocator.hpp. Unfortunately clearing memory is slow as hell. The time
complexity of copying gc is proportional to the number of surviving
objects. But if you want to clear memory too it becomes proportional to the
total number of allocated objects.

Plus, relying on the gc to zero out sensitive memory is a bad idea. You
never know when the gc runs or if it runs at all. That's why it is
considered bad practice in Java to use finalizers. I think it would be
better to use the destructors vocab to implement zeroing out of sensitive
memory.

2018-01-16 23:17 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:

> Hello!
>
>   I was reading a manual on the `8th` language, and noticed an interesting
> feature.
>   Apparently, it's possible to call a word on a memory buffer and thereby
> mark it as "sensitive information".
>   GC would zero the memory upon release.
>
>   Zeroing every bit of memory on release would add a lot of overhead (as I
> understand), but selectively clearing it like this could help with security
> applications that deal with certificates and passwords and stuff. This is
> especially useful, because in Factor GC can relocate (= copy) objects in
> memory. Does it clean up the memory it copied?
>
>   Do we have such a feature? Is it difficult to implement?
>   Bjourne, you've seen a lot of the runtime, can you comment?
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Disassembly

2018-01-17 Thread Björn Lindqvist
The mov [rip-0x117cfdf], eax instruction is indeed peculiar. It actually is
polling a safe point. When ctrl-c is pressed, the running thread is ordered
to stop as quickly as possible. It can't just halt anywhere but must
continue to execute until it comes to a point where it is safe to halt -- a
safe point. Meanwhile, the VM has set the memory page at address rip-0x117cfdf
to write protected which makes it so the instruction triggers a page
fault.  You can see how it is handled in the memory_signal_handler_impl()
function in errors.cpp This page explains safe points in more detail:

http://psy-lob-saw.blogspot.se/2014/03/where-is-my-safepoint.html

r14 contains the datastack top pointer. It is incremented by 0x10 which is
16 bytes or 2 cells. Your code was supposed to put two items on the stack,
but then the optimizer did a great job and noticed that the values didn't
have to be put on the stack but could be kept in registers. But it didn't
optimize away the stack increment/decrement. Possibly, the optimizer in
0.96 or 0.97 did a better job at optimizing code like that.



2017-10-12 23:32 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:

>
> Hello!
>
>   I'm trying to make sense of some disassembled code. Could someone help
> me out here?
>
> ```
> IN: scratchpad [ 256  [ drop ] each ] disassemble
> 001a8dbcdfc0: 89053a30e8fe  mov [rip-0x117cfc6], eax !
> What's this?
> 001a8dbcdfc6: b80001mov eax, 0x100
> 001a8dbcdfcb: 31db  xor ebx, ebx
> 001a8dbcdfcd: 4983c610  add r14, 0x10
> 001a8dbcdfd1: e90900jmp 0x1a8dbcdfdf (( gensym ) + 0x1f)
> 001a8dbcdfd6: 48ffc3inc rbx
> 001a8dbcdfd9: 89052130e8fe  mov [rip-0x117cfdf], eax !
> What's this?
> 001a8dbcdfdf: 4839c3cmp rbx, rax
> 001a8dbcdfe2: 0f8ceeff  jl dword 0x1a8dbcdfd6 (( gensym ) + 0x16)
> 001a8dbcdfe8: 4983ee10  sub r14, 0x10
> 001a8dbcdfec: 89050e30e8fe  mov [rip-0x117cff2], eax !
> What's this?
> 001a8dbcdff2: c3ret
> 001a8dbcdff3:   add [rax], al
> 001a8dbcdff5:   add [rax], al
> 001a8dbcdff7:   add [rax], al
> 001a8dbcdff9:   add [rax], al
> 001a8dbcdffb:   add [rax], al
> 001a8dbcdffd:   add [rax], al
> 001a8dbcdfff: 00invalid
> ```
>
>   The lines like `mov [rip-0x117cfdf], eax` I read as "copy the contents
> of the EAX register to a memory location pointed to by a memory address
> relative to the current Instruction Pointer register (rIP)". Am I right? If
> so, why is that being done inside the loop, and twice at the procedure
> entry and exit?
>
>   Also, why is the register r14 incremented by 0x10 on entry, and
> decremented on exit? What is r14 used for?
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] FUNCTION:

2018-01-17 Thread Björn Lindqvist
You can use the dlsym? word: "func_name" "lib_name" dlsym? For functions in
user32.dll, I think you should use "func_name" f dlsym?

2017-08-23 12:25 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:

>
> 23.08.2017, 05:14, "John Benediktsson" <mrj...@gmail.com>:
> > I'm not aware of any easy method. Maybe some other windows dev can
> comment. In macOS we check for the presence of a selector before calling.
> And in other places we version check before making an API call. Maybe that
> is what you need to do? If it's easy to determine what version ranges it
> was provided in.
>
>   OK, thanks for the reply.
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Concatenative Cert Expired

2017-06-24 Thread Björn Lindqvist
Indeed, we really need to update that servers certificate.

2017-05-04 12:32 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:

> Hello!
>
>   This is the message I get from Firefox:
>
> concatenative.org uses an invalid security certificate.
> The certificate expired on March 22, 2017 г., 22:38.
> The current time is May 4, 2017 г., 13:29.
> Error code: SEC_ERROR_EXPIRED_CERTIFICATE
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Effects Explained

2017-06-23 Thread Björn Lindqvist
I think there is some similar functionality in the trace vocab. [ quot ]
trace prints all words the quotation visits. It could be extended to also
print the datastack at each stepping point.

2017-05-01 22:00 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:

> Hello!
>
>   Have you guys seen this gist?
>
>   https://gist.github.com/anonymous/6ec7128c10e9ea1f63ad
>
>   Does it look like something worth including in the Listener (or FUEL)
> somehow?
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Slava's Factor blog - posts before 2005

2017-06-23 Thread Björn Lindqvist
I absolutely agree! Some of his earlier posts appear to have almost
completely dropped of the internet. Perhaps we can allocate space in our
Factor repository for the the text of his (and other authors) blog posts?
Like in a /docs/ hierarchy. It's the same with Manfred von Thun's text
which haven't been archived somewhere either.

2017-04-01 6:10 GMT+02:00 Sankaranarayanan Viswanathan <
rationalrev...@gmail.com>:

> Hi,
>
> There's a lot of useful ans interesting information about Factor's
> evolution that is documented in Slava's blog. The earliest[1] post there
> is from 2005 which has a link to a jroller blog that isn't online
> anymore. Its not on the archive.org either.
>
> Is the information from that blog still available somewhere? I'm
> interested in reading through the early evolution of Factor, and I think
> it would be useful to collect and keep the information in those old
> blog(s) alive somehow (with Slava's permission of-course).
>
> Thanks,
> Sankar
>
> [1]:
> http://factor-language.blogspot.com/2005/09/welcome-to-my-new-weblog.html
>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] LLVM

2017-03-19 Thread Björn Lindqvist
What do you mean by support? :) There is no llvm backend for the compiler
if that is what you mean. But there is an llvm binding in unmaintained/llvm
 which I played with a while ago and seem to work fine. It probably needs
to be updated to work with the latest llvm.

2017-03-16 16:33 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:

> Hello!
>
>   Is Matthew Willis on this list.
>   What is the status of the LLVM support by Factor?
>
> ---=---
>  Александр
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] when-empty

2017-03-01 Thread Björn Lindqvist
gt; engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
> ,
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ---=---
> Александр
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Security Applications

2017-02-28 Thread Björn Lindqvist
2017-02-25 20:24 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
>   Thanks for the links to those who replied. I agree that the proper way 
> seems to be to store the encryption key in a malloc'd buffer, which would 
> take it out of reach of the GC.


That's a very interesting question. Clearly, you need to allocate a
buffer for it outside the gc-managed heap. But I wonder if that is
sufficient. Freeing doesn't clear the buffer, and if you malloc again,
the buffer can be reused for that allocation. Clearing with memset
could also fail to get rid of the data if the memory system decides to
play optimization tricks.


-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] EOL

2017-02-15 Thread Björn Lindqvist
ourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>>
>>
>> ---=---
>> Александр
>>
>>
>>
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Startup time

2017-02-15 Thread Björn Lindqvist
It's like this. You are asking the restaurant to serve you a $1
hamburger and are getting annoyed because the chef is preparing a five
course dinner. :) It is fair to want a $1 hamburger quickly, but a
restaurant not specialized in serving them might not be able to make
one that fast.

In this case, Factor starts a whole integrated development
environment, complete with a compiler and gui, but you are just
interested in running a small script. One solution is running Factor
as a server. It's not bad, I do it all the time and IPC between Emacs
and Factor works really smooth. It could work just as well between
Factor and Bash. But if you aren't willing to accept that solution
then it is hard to solve your problem because Factor's startup time is
IO bound. E.g take a look at:

#include 
#include 

int main(int argc, char *argv[]) {
FILE *f = fopen("/home/bjourne/pubwork/factor-orig/factor.image", "rb");
fseek(f, 0L, SEEK_END);
long size = ftell(f);
fseek(f, 0L, SEEK_SET);
char *heap = malloc(size * 3);
fread(heap, size, 1, f);
long chk = 0;
for (long n = 0; n < size; n += 200) {
chk += heap[n];
}
printf("%ld\n", chk);
free(heap);
fclose(f);
return 0;
}

On my computer, with the factor.image file hot, running this example
takes 140 ms and ./factor -e='' 240 ms. So as you can see, reaching
Bash's startup time isn't realistic. Even an image 1/10th the size of
the standard one (118 mb) would take roughly 24 ms to load which is
still much slower than Bash.

Afaik, almost no language runtime can compile and interpret source
files nearly as fast as Bash.

2017-02-02 10:09 GMT+01:00  <pet...@riseup.net>:
> No need to apologize, as far as I'm concerned we're just discussing :)
> Now I hope I didn't sound too rude. I'm just trying to get on the same
> page with everyone. The provided solutions are in the line of "if the
> initialization is taking longer than you'd like, here's a way how to
> initialize only once". My focus is somewhere else though - why is the
> initialization taking so long? John is saying there's room for
> improvement, room to do less.
>
> --


-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Macros needed?

2017-02-15 Thread Björn Lindqvist
I think the key is to use the nth word instead of first and second.
Then do it like this:

  { "a" 2 3 } { "b" 5 6 } 2 random 0 = 0 1 ? rot over [ swap nth ] 2bi@

In your code it would be:

  dim chart chart-axes vert? 0 1 ? rot over [ swap nth ] 2bi@

Or

  dim chart chart-axes vert? 0 1 ? [ swap nth ] keep rot nth

Or even:

  dim chart chart-axes vert? 0 1 ? '[ _ swap nth ] bi@


2017-02-04 2:31 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> That's great!
>
>   I did this:
>
> : ?[x/y] ( ? -- quot )
> [ x ] [ y ] ? [ call( a -- b ) ] curry ; inline
>
> ...
> dim chart chart-axes vert? ?[x/y] bi@
>
> 04.02.2017, 04:29, "John Benediktsson" <mrj...@gmail.com>:
>> Well I'm not sure about the compiler effect declaration, but you could do 
>> this:
>>
>> vert? [ x ] [ y ] ? [ call( a -- b ) ] curry
>>
>>>  On Feb 3, 2017, at 5:04 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>>>
>>>  vert? [ x ] [ y ] ? check-effect( a -- b )
>>
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> ---=---
>  Александр
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Threaded Code?

2017-02-15 Thread Björn Lindqvist
Yes, you are right! But the Wikipedia article talks about many
different techniques. It talks about storing subroutine addresses into
arrays and having the system execute code by calling each of those
addresses in turn, like a byte-code interpreter. That's not what
Factor does because indirectly calling addresses in arrays is bad for
performance.

The method Factor uses is to generate one CALL instruction for each
word in the quotation being compiled. It's a really trivial technique.
A quotation like [ word-a word-b + ] would become roughly:

(word-prologue)
CALL address-of(word-a)
CALL address-of(word-b)
(word-epilogue)
JMP address-of(+)

2017-02-01 3:13 GMT+01:00 Levi Pearson <levipear...@gmail.com>:
> https://concatenative.org/wiki/view/Factor/Non-optimizing%20compiler
>
> Apparently the JIT for the interactive non-optimizing compiler generates
> subroutine threaded code with some inlining.
>
> I wouldn't call it a compiler optimization; maybe an interpreter
> optimization or a simple compiling technique. I think you hear about it a
> lot with respect to Forth and its family because of the proportion of Forth
> users who implemented the language or at least learned how it was
> implemented, although often modern Forth implementations have optimizing
> compilers. But the earliest academic reference I've seen for threaded code
> was in reference to a Fortran compiler for the PDP-11:
> http://home.claranet.nl/users/mhx/Forth_Bell.pdf
>
> I'm pretty sure that 1971 article was more of a description of a technique
> already widely in practice (i.e. a description of "folklore") rather than a
> new invention, so it's definitely been around a whlie.
>
> I wrote a simple threaded code interpreter in C as an exercise to understand
> them better a while back; including some conditionally-compiled debug code
> and a fairly small complement of core Forth words and an outer interpreter
> loop, it's still well under 1k lines of source.
>
> --Levi
>
> On Tue, Jan 31, 2017 at 3:23 PM, Björn Lindqvist <bjou...@gmail.com> wrote:
>>
>> Probably not! I've never heard of that technique. From skimming that
>> Wikipedia article it seem to be a compiler optimization invented a
>> long time ago. We have an instruction called ##dispatch, used for
>> method dispatching, but it is not nearly as dynamic as the method
>> described. Probably for the best because on modern processors jumping
>> to addresses kept in memory or in registers is very bad for
>> performance.
>>
>>
>> 2017-01-31 21:11 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
>> > Hello!
>> >
>> >   Does Factor use threaded code in any way?
>> >   https://en.wikipedia.org/wiki/Threaded_code
>> >
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] maybe{

2017-01-29 Thread Björn Lindqvist
2016-12-24 12:21 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
>   You see those `maybe{` words? What are they, I wondered, and looked up 
> their help. It was empty.

They are classoids! Don't try looking up the documentation for that,
it isn't there. :)

>   Yet it works exactly the way I wanted: it allows you to assign either the 
> specified type(s) or `f` to a slot.
>
>   That's a very useful feature, and it seems to be there for five years! But 
> why is it not described or even mentioned?

Maybe (hahah) because it is part of the class algebra system and it is
a complicated part of Factor. So no one has spent the time to
understand it fully and write documentation for it. It contains some
really cool features:

integer rational class<=
t
rational real class<=
t
integer real class<=
t

"The set of all integers is small than the set of all rationals which
in turn is smaller than the set of all real numbers." I agree it would
be useful with more documentation in this area.


-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Ratio vs. Float

2017-01-19 Thread Björn Lindqvist
If you enter -81/2 instead of -40.5 it should work.

2017-01-20 0:07 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Thank you, Jon, now I understand what the problem is.
> Unfortunately, in my case I can't use `number=` because the comparison is
> done by the unit-test word.
> In the following code the first test succeeds, but the second one fails:
>
> ```
> { 15 } [ 10 20 middle ] unit-test
> { -40.5 } [ -50 -31 middle ] unit-test
> ```
>
> 20.01.2017, 01:30, "Jon Harper" <jon.harpe...@gmail.com>:
>
> Hi,
> you have to use number= to compare numbers with different types.
> http://docs.factorcode.org/content/word-number=,math.html
>
> Jon
>
> Jon
>
> On Thu, Jan 19, 2017 at 10:50 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>
> Hello!
>
>   I'm a bit confused. Why is following not true?
>
>   `81/2 40.5 =`
>
> ---=---
>  Александр
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> ,
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
> ,
>
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ---=---
> Александр
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Accumulation of subsequences

2016-12-16 Thread Björn Lindqvist
I think you can use group-by from sequences.extras. It works similar
to map-runs:

{ 1 5 "hello" 2 "world" 3 6 9 "!" } [ integer? ] group-by [ swap [ sum
] [ first ] if ] { } assoc>map .
{ 6 "hello" 2 "world" 18 "!" }


2016-12-16 11:16 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   I was solving this issue, and it got me wondering if there is a better 
> solution somewhere in the library. Could you check this out?
>
>   I want to find consecutive runs of numbers and replace them with a sum, 
> while preserving all other objects in the sequence (currently only strings 
> are in there). For example:
>
> IN: { 1 5 "hello" 2 "world" 3 6 9 "!" } collapse-numbers
> OUT: { 6 "hello" 2 "world" 18 "!" }
>
>   Here's the `collapse-numbers` implementation that I came up with:
>
> :: collapse-numbers ( seq -- seq' )
> f :> accum! seq [
> accum 2dup [ number? ] both? [
> + accum! f
> ] [
> swap accum!
> ] if
> ] map sift accum suffix ;
>
>   Using a local variable for a side-effect in map feels like cheating, 
> straight from my imperative programming background.
>   Is there a way to, maybe, convert numbers into subsequences?
>
> IN: { 1 5 "hello" 2 "world" 3 6 9 "!" } [ number? ] map-runs
> OUT: { { 1 5 } "hello" { 2 } "world" { 3 6 9 } "!" }
>
>   If we had something like `map-runs`, the whole task could be solved in a 
> more functional way:
>
> : collapse-numbers ( seq -- seq' )
> [ number? ] map-runs [ dup string? [ sum ] unless ] map ;
>
>   What are your thoughts on this? Do we **have** something like `map-runs`? 
> Do we **need** it? Should I have used PEGs to parse the sequence?
>
> ---=---
>  Александр
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] $related

2016-12-14 Thread Björn Lindqvist
I think there is a bug with related-words. Like if foo is loaded but
not bar, then the "See also" header will only show for the foo word,
but not the bar word. It happens if the words in the related-words
sequence are in different vocabs.

2016-12-14 14:07 GMT+01:00 John Benediktsson <mrj...@gmail.com>:
> You save typing by using related-words which we use everywhere in the docs.
>
> { foo bar baz } related-words
>
> I'm just trying to help you with your $see-also, which I thought you were 
> trying to do...
>
>> On Dec 14, 2016, at 4:52 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>>
>> Hello!
>>
>> 14.12.2016,  15:39, "John Benediktsson" <mrj...@gmail.com>:
>>> P.S., you should be able to use $see-also the way you want to use $related.
>>
>>  Well, I had this weird notion that if I use `$see-also`, I need to use it 
>> **in both words** to mutually link them, but if I use `$related` instead, I 
>> could use it **in either word** to make the mutual link. I wanted to save 
>> myself some typing.
>>
>> ---=---
>> Александр
>>
>> --
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Libudis86.dll (Was: TYPED: Declarations)

2016-11-25 Thread Björn Lindqvist
It is easiest if you put the builds online somewhere and open an issue
referencing them. Then John and Doug can add them to the dll directory
here: http://downloads.factorcode.org/dlls/ That the files you have
built are smaller than the existing ones can be good or bad. I've
found that it is often hard to control what dependencies VS will add
to dlls you build. Sometimes it will decide to link to debug libraries
and such. But you can check that with the excellent depends.exe
utility: http://www.dependencywalker.com/

2016-11-25 9:22 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Thank you, John, that was very helpful!
>
>> P.S., I think 32-bit libudis86.dll exists somewhere, and I know 32-bit
>> libudis86 is supported on other OS's.
>
> I have found the sources here: https://github.com/vmt/udis86
>
> I happen to have VS2010, so I managed to build both 64- and 32-bit versions
> of the DLL, v1.7.2. I can contribute those if you tell me the way.
> BTW, for some reason my 64-bit build DLL file is smaller than the one at
> http://downloads.factorcode.org/dlls/64/
> Maybe that's good.
>
> Anyway, when testing the thing under 32-bit I found an issue, of which I'm
> not sure whether it's ours or theirs:
>
> IN: scratchpad : test2+ ( n -- n )  2 + ;
> IN: scratchpad \ test2+ disassemble
> 083c2c10: a300106907mov [0x7691000], eax
> 083c2c15: 83c604add esi, 0x4
> 083c2c18: c7062000  mov dword [esi], 0x20 ! > This should be
> 0x02
> 083c2c1e: a300106907mov [0x7691000], eax
> 083c2c23: ba2d2c3c08mov edx, 0x83c2c2d (test + 0x1d)
> 083c2c28: e903465bffjmp 0x7977230 (+)
> 083c2c2d:   add [eax], al
> 083c2c2f:   add [eax], al
> 083c2c31:   add [eax], al
> 083c2c33:   add [eax], al
> 083c2c35:   add [eax], al
> 083c2c37:   add [eax], al
> 083c2c39:   add [eax], al
> 083c2c3b:   add [eax], al
> 083c2c3d:   add [eax], al
> 083c2c3f: 00invalid
>
> The same issue is present in the 64-bit build of the libudis86.dll
> downloaded from http://downloads.factorcode.org/dlls/64/
>
> It can also be reproduced using their command-line client:
>> echo a3 00 10 69 07 83 c6 04 c7 06 20 00 00 00 | udcli -x
>  a300106907   mov [0x7691000], eax
> 0005 83c604   add esi, 0x4
> 0008 c7062000 mov dword [esi], 0x20
> All three lines of the above output have half-bytes swapped in the mnemonics
> (0x20 instead of 0x2, 0x4 instead of 0x40, etc.).
>
> This begs the question: do we supply bad data to the disassembler, or does
> disassembler misinterprets what we give it?
>
> ---=---
> Александр
>
>
> --
>
> _______
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Out Of Memory

2016-11-23 Thread Björn Lindqvist
Hi,

It shouldn't crash exactly, but it does terminate the process with an
"Out of memory" error.

2016-11-23 20:43 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   What happens if Factor is out of memory?
>   Does it throw an exception and aborts the current operation? Or does it 
> simply crash the instance?
>   For me it simply crashes, which is not very nice.
>
> ---=---
>  Александр
>
> --
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Web scraping

2016-11-18 Thread Björn Lindqvist
I think the reason it is parsed into a vector of start and end tags is
because it is much simpler when not all of the html data is available.
Or you are dealing with broken html code. There is no real XPath
support in any Factor vocab as far as I'm aware of. I once wrote a
half-completed binding for libxml2 (which has XPath support and a lot
of other goodies) when I also needed it, but then I got side-tracked
with other things I wanted to build. And the words in
html.parser.analyzer were "good enough" for my use case. It's not so
hard to use them to do the same kind of querying you would with XPath.

So for example, if you have the result of
"https://news.ycombinator.com/; scrape-html nip on the stack:

//a//text() ->
[ name>> "a" = ] find-between-all [ [ name>> text = ] filter
[ text>> ] map " " join ] map

//@href ->
[ "href" attribute ] map sift

//table[@class="itemlist"]/td[@class="storylink"]/(text() or @href) ->
[ "itemlist" html-class? ] find-between-all first
[ "storylink" html-class? ] find-between-all
[ [ first "href" attribute ] [ second text>> ] bi 2array ] map

XPath expressions look better, but this works just fine.

2016-11-19 0:32 GMT+01:00  <pet...@riseup.net>:
> Hello again :)
>
> I'm looking at implemented options of scraping web pages? I've hit into
> this
>
> http://re-factor.blogspot.nl/2014/04/scraping-re-factor.html
>
> but that's a json output and I'm looking at pages that only have html. I
> see there's parse-html and scrape-html to parse a url into a vector,
> which seems like an html tree flattened to an (event) stream. I'm left
> to wonder about the choice as it is unusual to my eyes, but I found
> there's a bunch of words working with the output in
> html.parser.analyzer. I've fiddled around with it and found my way
> around to extract some components I was looking for.
>
> So now I'm wondering - is there anything else I've missed. Is there
> something that parses html into a tree structure? Is there some simpler
> DSL to extract data? The common cases I hit into are XPath and CSS
> selectors, which are short and to the point, but I'm fine with w/e that
> is easy enough and has the same power. So basically I'm just looking for
> more tips or options in case I missed something. You guys have a lot of
> vocabs :)
>
> --
> 
>Peter Nagy
> 
>
> ------
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Dedupe by Slot

2016-11-18 Thread Björn Lindqvist
2016-11-18 15:36 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello, all!
>
>   I have an interesting little task for you today.
>
>   Let's say you have a sequence of tuples, and you want to remove all tuples 
> with duplicate ids, so that in the new sequence there is only one tuple with 
> each id.
>
>   Here's my solution:
>
> TYPED: dedupe-by-hash ( seq: sequence -- seq: sequence )
> dup [ hash>> ] map >hash-set [
> [ hash>> ] dip
> [ in? ] [ delete ] 2bi
> ] curry filter ;
>
>   This is not the first time I'm solving this task, and I begun to wonder - 
> is there something similar in the Factor library?

Everything is in the Factor library. :) What you are describing is
like a group by operation in sql. So if you have:

TUPLE: person name id ;

You can use either:

USE: sequences.extras
[ id>> ] sort-with [ id>> ] group-by [ second first ] map

Or

USE: math.statistics
[ id>> ] collect-by [ nip first ] { } assoc>map

If you want tiebreakers, like choosing the person with the
alphabetically first name if more than one share id, you can implement
it like this:

USE: slots.syntax
[ slots{ id name } ] sort-with [ id>> ] group-by [ second first ] map

It's not as efficient as what John committed though. :) Maybe we
should try and clean it up somehow? If we put all group
by/aggregation/uniquifying words in the same vocab it would be more
easily discoverable?


--
mvh Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Listener in a Different Context

2016-11-09 Thread Björn Lindqvist
Your original code works for me on Linux. Might be the Windows UI
backend doing something incorrect.

2016-11-09 20:30 GMT+01:00 Alexander Ilin <ajs...@yandex.ru>:
> Thank you, John!
>
> I can now try to make it work for my real use case:
> "d:/" [ [ listener-window ] with-my-db ] with-directory
>
> : )) with-db is a bit trickier, I believe, than set-current-directory.
> with-disposal, in particular : )
>
> 09.11.2016, 22:00, "John Benediktsson" <mrj...@gmail.com>:
>
> Everything is possible, with varying amounts of work.
>
> This as it turns out is fairly easy but maybe requires defining a new word
> to make it easy.  Here is one way:
>
> : run-in-new-listener ( quot -- )
> '[
> _ \ run-in-new-listener listener-window*
> dup wait-for-listener (call-listener)
> ] with-ui ;
>
> Using it:
>
> [ "d:\" set-current-directory ] run-in-new-listener
>
>
>
> ---=---
> Александр
>
>
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Search Files by Name

2016-10-29 Thread Björn Lindqvist
Perhaps you can use ant-globs. Like this:

USE: globs
"/the/dir" [ "**/progname*" glob ] with-directory

It appears to fold case by default so it should match any PROGNAME
files too. It also matches directories which you might want to filter
out.

2016-10-29 16:41 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> What's the best way to search for all files matching a pattern "progname.*"?
> Note: in Windows the "name" part is case-insensitive.
>
> I see that we have `find-by-extension` in `io.directories.search`, but
> nothing to search by name.
>
> I want to find and scan all log-files in a folder, created by a program that
> uses "progname." scheme for naming its files, and the casing in the
> "progname" part is not always the same.
>
> If I were using FindFirstFile/FindNextFile WinAPI, I would have just
> supplied the "progname.*" mask, but I see no way to supply the mask via the
> high-level calls, and I don't want to allocate the platform-specific
> ``s in my code.
>
> What would be the best way to search for the thing I need? Do we have a
> case-insensitive regexp matcher?
>
> ---=---
> Александр
>
>
> --
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> _______
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] restricting ratio literals

2016-10-26 Thread Björn Lindqvist
Imho, choose based on what makes the implementation better. If the
parser can be written in a simpler (and probably faster) way by
dropping support for ratios in uncommon bases, then let's do it. Tbh,
I don't think any ratios other than those on the format int1/int2
needs to be supported.

2016-10-24 19:23 GMT+02:00 Jon Harper <jon.harpe...@gmail.com>:
> Hi list,
> I'm reading the questions at https://github.com/factor/factor/pull/1362
> again
>
> I think we should only allow ratio literals in base 10. Currently we support
> 0xc+b/a or 0o4+7/3 or 0b1101+1101/110 but it looks ugly.
>
> What do you think ?
>
> Jon
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor As Scripting Language

2016-10-26 Thread Björn Lindqvist
A Factor version of the C function Beached is posting would be a nice
addition to the windows.privileges vocab.

2016-10-25 23:05 GMT+02:00 Doug Coleman <doug.cole...@gmail.com>:
> Take a look at basis/windows/privileges/privileges.factor and
> http://stackoverflow.com/questions/8046097/how-to-check-if-a-process-has-the-administrative-rights
>
> On Tue, Oct 25, 2016 at 1:49 PM Onorio Catenacci <catena...@ieee.org> wrote:
>>
>> This issue is that certain tasks require administrator privilege on
>> Windows and it's much more friendly to check the current user's
>> privileges and inform the user that he or she needs to elevate to
>> admin than simply fall over. :)
>>
>> Sadly before Windows 7 most users are on their machine as admins by
>> default (which is, truly, a large part of the reason that Windows was
>> such a fruitful hunting ground for people who liked to spread
>> trojans).  A lot of users still have admin privileges by default but a
>> few are smart enough to practice least-privilege.
>>
>> --
>> Onorio
>>
>> On Tue, Oct 25, 2016 at 4:35 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>> >
>> > 25.10.2016, 23:13, "Doug Coleman" <doug.cole...@gmail.com>:
>> >
>> > You should be able to call the Windows APIs directly (if you can figure
>> > out
>> > which ones!) and avoid using a script to call a binary.
>> >
>> >
>> > That's true. I'm simply having fun with that little task. Parsing the
>> > output
>> > and such.
>> > If I needed to solve that problem in a proper way, I would not mess with
>> > the
>> > whoami.exe, I'd look for WinAPI functions.
>> > I'm not familiar with those, so can't really help here.
>> >
>> > I have an issue with the formulation of the task, though. Why do we need
>> > to
>> > know if a user is an admin? Do we strictly want to check the
>> > Administrators
>> > group membership, or do we want to test for some specific access
>> > privileges?
>> > For instance, Power Users used to have some pretty big rights in their
>> > day,
>> > without being full admins.
>> > There is also the issue with elevation, which gives a user some rights
>> > without making him/her an admin.
>> >
>> >
>> > http://stackoverflow.com/questions/581204/how-do-i-check-if-a-user-has-local-admin-privileges-in-win32
>> >
>> > http://stackoverflow.com/questions/8046097/how-to-check-if-a-process-has-the-administrative-rights/8196291#8196291
>> > https://support.microsoft.com/en-us/kb/118626
>> >
>> > ---=---
>> > Александр
>> >
>> >
>> >
>> > --
>> > The Command Line: Reinvented for Modern Developers
>> > Did the resurgence of CLI tooling catch you by surprise?
>> > Reconnect with the command line and become more productive.
>> > Learn the new .NET and ASP.NET CLI. Get your free copy!
>> > http://sdm.link/telerik
>> > ___
>> > Factor-talk mailing list
>> > Factor-talk@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/factor-talk
>> >
>>
>>
>>
>> --
>> Onorio Catenacci
>>
>> http://onor.io
>> http://www.google.com/+OnorioCatenacci
>>
>>
>> --
>> The Command Line: Reinvented for Modern Developers
>> Did the resurgence of CLI tooling catch you by surprise?
>> Reconnect with the command line and become more productive.
>> Learn the new .NET and ASP.NET CLI. Get your free copy!
>> http://sdm.link/telerik
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
> --
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] prettyprinter number-base float errors

2016-09-16 Thread Björn Lindqvist
Hi!

Seems logical to me if printing floats worked in binary and octal too.
So if it is not to hard to implement, I think adding support for
printing floats in binary and octal is the right way to go.


2016-09-11 14:03 GMT+02:00 Jon Harper <jon.harpe...@gmail.com>:
> Hi list,
> I'm working on factor's number parsing/printing. I'd like some inputs on the
> following problem:
>
> Basically the problem can be seen from this paste:
> http://pastebin.com/jxV8UKG2 : setting number-base to 2 or 8 gives
> pprint-errors for floats.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Could not initialize OpenAL

2016-09-14 Thread Björn Lindqvist
2016-09-14 23:53 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> 15.09.2016, 00:16, "Björn Lindqvist" <bjou...@gmail.com>:
>
>
>
> But you can download soft_oal.dll from the OpenAL soft package:
> http://kcat.strangesoft.net/openal-binaries/ Rename that file to
> OpenAL32.dll and put it in the same directory as factor.exe and the
> alut.dll file. Then it works for me. I think that means you only get
> "software" audio without hardware support so no 3d audio or any fancy
> features like that. But who cares. :) I don't think many sound cards
> supports OpenAL any way.
>
>
> Wow, it did work. I was able to run the "jamshred" demo. Thank you, Björn!
> Interestingly, I didn't hear any sound from that thing. Maybe it doesn't use
> alut after its initialization? : )
>
> The Space Invaders and the Balloon Bomber say they need the ROM files.
> Does anyone know where do I get those?

I don't know about jamshred, but you can run play-hello and if OpenAL
works it should say "Hello world". You can find the ROMs for Balloon
Bomber and other games here:

http://www.emuparadise.me/M.A.M.E._-_Multiple_Arcade_Machine_Emulator_ROMs/Balloon_Bomber/11301-download

(download at your own risk ;))

Then unzip to something like "C:/code/tmp/ballbomb" and set rom-root:
"C:/code/tmp/" rom-root set-global Then you can call run-balloon. On
Windows something is off with the timers so the cpu runs to fast which
makes the game unplayable. But it works well on Linux.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Could not initialize OpenAL

2016-09-14 Thread Björn Lindqvist
2016-09-14 18:32 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> 14.09.2016, 17:04, "Björn Lindqvist" <bjou...@gmail.com>:
>
> f f alutInit drop alutGetError alutGetErrorString
>
> And see what error message you get.
>
>
> "There was an error opening the ALC device"
>
> I'm not on Win10, but rather Win8 Pro 64-bit.

It appears it works something like this: OpenAL32.dll is the public
API, but not the whole OpenAL implementation. Exactly like OpenGL
works. Having the OpenGL dll is not enough, you also need drivers
installed to support it which neither you nor I have.

But you can download soft_oal.dll from the OpenAL soft package:
http://kcat.strangesoft.net/openal-binaries/ Rename that file to
OpenAL32.dll and put it in the same directory as factor.exe and the
alut.dll file. Then it works for me. I think that means you only get
"software" audio without hardware support so no 3d audio or any fancy
features like that. But who cares. :) I don't think many sound cards
supports OpenAL any way.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Could not initialize OpenAL

2016-09-14 Thread Björn Lindqvist
2016-09-12 8:32 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Win 8x64, Factor 32-bit.
>
> I'm trying to run some demos, and they say I need alut.dll and openal32.dll,
> both of which I've downloaded and placed in the Factor.exe folder.

It actually is the OpenAL32.dll with the special casing you need.
That's the name alut.dll and the alut vocab references. It might not
matter because Windows' filesystem is case-insensitive.


> When I click some of the buttons on the `"demos" run` page I see some
> modules loading, and then "Could not initialize OpenAL" with the Abort
> option.
> Is it just me, or do some other people have the same issue?

I also have it. It could be that the OpenAL version in the dlls aren't
compatible with the sound system in Windows 10. I think Windows and
OpenAL has always been a bit of trouble. You can try:

f f alutInit drop alutGetError alutGetErrorString

And see what error message you get.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] +foreign-id+ seems to protect unused entries too

2016-08-25 Thread Björn Lindqvist
> If I remove ``{ +foreign-id+ node "ID" }`` all works fine.
>
> Do I understand ``+foreign-id+`` wrong ?

There was a bug in the delete restrict triggers. Should be fixed now.

> tree "TREE" {
> { "id"  "ID"INTEGER +db-assigned-id+ }
> ! { "node""NODE"  INTEGER }
> { "node""NODE"  INTEGER { +foreign-id+ node "ID" } }
> } define-persistent

You can also use: { "node" "NODE" INTEGER { +foreign-id+ node "ID" }
+on-delete+ +cascade+ } to get cascading deletes. IME, that is almost
always better than restricting deletes.

> "test.db"
> [ "rm " prepend system drop ]

You could use [ ?delete-file ] here.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] USING: cleanup

2016-08-11 Thread Björn Lindqvist
If you are using Emacs and FUEL, then you can press C-c C-e C-u and it
will automatically cleanup and alphabetize the USING list for you.

2016-08-11 1:18 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   Is there a way to clean-up the USING: list of a vocab by removing the no 
> longer needed entries?
>
> ---=---
>  Александр


-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] GitHub

2016-08-10 Thread Björn Lindqvist
I am, but I had forgot to turn my visibility to public. Thanks for reminding me!

2016-08-10 17:19 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   How come @bjourne is not in https://github.com/orgs/factor/people ?
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. http://sdm.link/zohodev2dev
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Font

2016-07-29 Thread Björn Lindqvist
I think adding the images to the image would be neat. The icon for
Factor is already embedded in the image like you suggest. You can see
the code for that in basis/ui/backend/gtk/gtk.factor. Something like
that could be generalized to work for other images too. Then if you
are making a game or something, all your assets would be neatly packed
into a single .exe file.

2016-07-25 18:34 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> 25.07.2016, 16:47, "John Benediktsson" <mrj...@gmail.com>:
>
> You can reset the memoized so then next time it gets called it will memoize
> again:
>
> IN: scratchpad \ windows-fonts reset-memoized
>
>
>
>   Hold on a second! Looking at the `startup-hooks`, I see one hook named
> "windows.fonts", and it does this:
> `[ \ (cache-font) reset-memoized ]`
>
>   Shouldn't we add `\ windows-fonts reset-memoized` to the same existing
> hook?
>
>
> You could probably put that in a .factor-rc if you need it run on startup.
>
>
>
>   No, I probably found a bug! : ) Let's fix the hook instead!
> https://github.com/factor/factor/pull/1678
>
>
> Why do you need those icon images cached in the Factor image?
>
>
>   I think it's a bit awkward to have everything in the image, except for the
> images.
>   Get it? Images?
>   Never mind.
>
> ---=---
> Александр
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.http://sdm.link/zohodev2dev
> _______
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] benchmark is rigged?

2016-07-29 Thread Björn Lindqvist
That is very interesting! I've looked at how Python does benchmarking
and it does not use QPC:

On Windows, QueryPerformanceCounter() is not used even though it has a
better resolution than GetTickCount() . It is not reliable and has too
many issues.

https://www.python.org/dev/peps/pep-0418/

So we could switch to use GetTickCount() instead but the drawback is
that that function has abysmal resolution. Then again, XP is a very
old operating system..


2016-07-24 23:43 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   It looks like adding the /usepmtimer switch to the boot.ini has fixed the 
> problem for that PC. At least the same test cases no longer reproduce the 
> error after a reboot.
>
>   Source of inspiration: http://www.virtualdub.org/blog/pivot/entry.php?id=106
>
> 24.07.2016, 21:59, "Alexander Ilin" <ajs...@yandex.ru>:
>> Hello!
>>
>>   I'm having a weird problem with the benchmark word on my WinXP SP3 32-bit 
>> machine, running the latest Factor from Github master.
>>
>>   The benchmark word reports times under or about 1 second (1,000,000,000) 
>> for some piece of code, but the actual run time of the quotation is always 
>> about 5-6 seconds.
>>
>>   For example, here's a sketch of a test session, without restarting a 
>> Factor instance, done in the following order.
>>
>>   This code would show running time < 1 sec:
>>
>> [ do-smth ] benchmark
>>
>>   Then this code would show the correct wall time for both the time word and 
>> the benchmark word:
>>
>> [ [ do-smth ] time ] benchmark
>>
>>   This would show the correct timing for both words as well:
>>
>> [ [ do-smth ] benchmark ] time
>>
>>   Finally, returning to this code again measures incorrectly (< 1 sec):
>>
>> [ do-smth ] benchmark
>>
>>   Has anyone experienced anything like this before?
>>
>>   Replacing [ do-smth ] with [ now do-smth now ] shows the correct time in 
>> all cases, and by calculating difference I can see that benchmark calculates 
>> incorrectly. But I can't figure out the reason.
>>
>>   On the other hand, replacing [ do-smth ] with [ nano-count do-smth 
>> nano-count ] I see that benchmark is right. So, the problem is that for some 
>> reason nano-count returns lower time difference for the code I run, 
>> depending on the way I run it - with or without the "time" word.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] nano_count()

2016-07-25 Thread Björn Lindqvist
Yes. :)

2016-07-24 23:48 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
>   In vm/gc.cpp:
>
> gc_event::gc_event(gc_op op, factor_vm* parent)
> : op(op),
>   cards_scanned(0),
>   decks_scanned(0),
>   code_blocks_scanned(0),
>   start_time(nano_count()),
>   card_scan_time(0),
>   code_scan_time(0),
>   data_sweep_time(0),
>   code_sweep_time(0),
>   compaction_time(0) {
>   data_heap_before = parent->data_room();
>   code_heap_before = parent->code->allocator->as_allocator_room();
>   start_time = nano_count();
> }
>
>   Isn't it redundant to initialize the start_time twice?
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity planning
> reports.http://sdm.link/zohodev2dev
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] handle-seekable?

2016-07-13 Thread Björn Lindqvist
This must be a bug. A stream backed by a file is seekable so 0 should
be returned as its length.

2016-07-08 1:32 GMT+02:00 John Benediktsson <mrj...@gmail.com>:
> Possibly not easy to tell at that point if it is a file or network descriptor 
> and the worst case is an additional read that returns EOF on an empty file?
>
>> On Jul 7, 2016, at 4:06 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>>
>> Hello, John!
>>
>>  TCP/UDP streams are not seekable, so it should return f, and it does. Why 
>> does it not return 0 for seekable empty (file) streams?
>>
>>  A bigger quote from the documentation:
>>
>> Word description
>> Returns the length of the data supplied by stream, or f if the stream is not 
>> seekable or has unknown length.
>>
>> Notes
>> Stream seeking is not supported on streams that do not have a known length, 
>> e.g. TCP/IP streams.
>>
>> 08.07.2016, 00:42, "John Benediktsson" <mrj...@gmail.com>:
>>> For tcp/udp file descriptors, they can return 0 length sometimes and we 
>>> want to then return `f` so we read to EOF.
>>>
>>>> On Jul 7, 2016, at 2:26 PM, Alexander Ilin <ajs...@yandex.ru> wrote:
>>>>
>>>> Hello!
>>>>
>>>>  OK, ignore that last message, I can see now that it works.
>>>>
>>>>  Another question, though. This one is about io.ports:
>>>>
>>>> M: buffered-port stream-length
>>>>handle>> handle-length [ f ] when-zero ;
>>>>
>>>>  Why does it never return 0? For instance, what if I open an empty file 
>>>> for reading, I'd expect it to return 0, and "f" only for streams that are 
>>>> not seekable.
>>>>
>>>> { 0 }
>>>> [
>>>>"empty.txt" binary [ input-stream get stream-length ] with-file-reader
>>>> ] unit-test
>>>>
>>>>  From the documentation on stream-length:
>>>> Word description
>>>> Returns the length of the data supplied by stream, or f if the stream is 
>>>> not seekable or has unknown length.
>>>>
>>>>  Why not return 0 so that I could test that with if-zero?
>>
>> ---=---
>> Александр
>>
>> --
>> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> ___
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
> --
> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San
> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
> present their vision of the future. This family event has something for
> everyone, including kids. Get more information and register today.
> http://sdm.link/attshape
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Hooking the Back End

2016-06-14 Thread Björn Lindqvist
In that scenario, you are supposed to start a new thread in which the
copying proceeds. Factor's IO is implemented as a blocking facade
around an asynchronous core. That's why the CopyFile call on Windows
is likely a bug, it is blocking for real. See this thread:
https://sourceforge.net/p/factor/mailman/message/32588643/

I also wonder if you are not working on a to low level for the
feature. The io backend hooks are mostly for encapsulating platform
differences and are hard to extend.


2016-06-15 0:18 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> But there is still a point in having a separate batch-processing backend.
> You see, if you start a copy operation in the Listener interactively, then
> even with the good variant of the copy-file you won't be able to continue
> working with the Listener until the copying is finished. Sure, it won't
> hang, and the caret will keep blinking, but you won't be able to queue the
> next file to be copied while the first one is still being handled. That's
> what my custom backend would do for you.


--
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421=/41014381
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-28 Thread Björn Lindqvist
Hello,

Here is some sample code to run:

USING: alien io kernel threads.private windows.kernel32
windows.types ;
IN: examples.windows.threads

: eternity ( -- ) eternity ;

:  ( -- alien )
DWORD { LPVOID } stdcall [ drop eternity 0 ] alien-callback ;

: start-thread ( -- handle )
f 0  f 0 f CreateThread ;

: main ( -- )
start-thread drop
"I am here" print flush
20,000,000,000 (sleep) ;

MAIN: main

As you can see, it taxes the cpu 100% which proves that the thread is
running. Then something triggers a gc and it crashes. It is not
unexpected.

You are kind of entering unexplored territory here. No one has ensured
that factor works correctly when running kernel threads containing
factor code. You aren't meant to do it.

However, you can start and run a thread written in C++ in the VM using
start_thread() as long as you are careful not to mess with the
factor_vm object in unapproved ways. You can see how it is done in
start_sampling_profiler_timer() in vm/os-windows.cpp.

I still don't understand how you can get that thread to trap the
ctrl+break key combo. But if you can, then great!


2016-05-27 22:16 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> 27.05.2016, 20:00, "Björn Lindqvist" <bjou...@gmail.com>:
>> Try defining  like this:
>>
>> :  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;
>
>   Tried this, see below.
>
>   I'm now at home, trying these things on Win 8.1 64-bit, on a freshly 
> bootstrapped Factor. (For some reason the build.cmd produced a 32-bit 
> executable, even though I'm on a 64-bit system.) The Windows Error Reporting 
> tool (WerFault.exe) says that an exception is happening. Sometimes I get to 
> see some kind of dumps in the console, sometimes not.
>
>   Here's my code:
>
> USING: kernel windows.kernel32
> alien alien.data alien.syntax windows.types ;
> IN: my-thd
>
> LIBRARY: kernel32
>
> FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
> SIZE_T dwStackSize,
> LPVOID lpStartAddress,
> LPVOID lpParameter,
> DWORD dwCreationFlags,
> LPDWORD lpThreadId )
>
> CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )
>
> :  ( -- alien )
>   [ [ t ] [ ] while ] ThreadProc ;
>
>
> :  ( -- alien )
>   DWORD { LPVOID } stdcall [ ] alien-callback ;
>
> :  ( -- alien )
>   DWORD { LPVOID } stdcall [ [ t ] [ ] while ] alien-callback ;
>
>
> : start-thd ( -- hnd )
> f 0  f 0 f CreateThread ;
>
> : start-thd-2 ( -- hnd )
> f 0  f 0 f CreateThread ;
>
> : start-thd-3 ( -- hnd )
> f 0  f 0 f CreateThread ;
>
>   Test runs and results:
>   start-thd: the app sometimes dies with no output. WerFault sometimes 
> reports Exception Code c409, which Googles to "Stack buffer overflow", 
> and sometimes c005, which is "access violation". Sometimes I see a 
> console dump, which starts with "fatal_error: Memory protection fault during 
> gc: ".
>
>   start-thd-2: most of the time dies with no output, but once I saw the text 
> "Error in print-error!" on the console.
>
>   start-thd-3: most of the time dies with no output, but once I saw a message 
> box with "Memory protection fault at address 0x105" in it.
>
>   Can you help me? I need more code to try.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Björn Lindqvist
Try defining  like this:

:  ( -- alien ) DWORD { LPVOID } stdcall [ ] alien-callback ;

2016-05-27 18:03 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello, John!
>
> 27.05.2016, 18:55, "John Benediktsson" <mrj...@gmail.com>:
>> If you run it from the command prompt does it print an error message when it 
>> exits?
>
>   As I said, no message boxes, nothing on the console.
>
> ---=---
>  Александр
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-27 Thread Björn Lindqvist
Hi,

>   OK, good. When I call CreateThread, one of the parameters I need to pass it 
> is a function pointer to the code which will run in the new thread. My 
> question is: can I pass a Factor quotation or a word as the function pointer? 
> Or is there some wrapper to make it possible, like with-new-vm or something?
>

Yes. See 
https://github.com/bjourne/playground-factor/wiki/Tips-and-Tricks-Alien#using-alien-callbacks
for an example on how to pass callbacks to c functions. So if
CreateThread has signature:

FUNCTION: HANDLE CreateThread ( LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPVOID lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId )

You need to declare a callback:

CALLBACK: DWORD ThreadProc ( LPVOID lpParameter )

Then a callback maker:

:  ( -- alien )
[ ] comparer ;  <-replace [ ] with your code

Then call it:

f 1024  f 0 1234 CreateThread


-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Build Factor on Windows with Win7 SDK

2016-05-26 Thread Björn Lindqvist
The one you download here is what I'm using:
https://go.microsoft.com/fwlink/?LinkId=691978=0x409

2016-05-27 0:05 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hey, Doug!
>
> 27.05.2016, 00:54, "Doug Coleman" <doug.cole...@gmail.com>:
>
> We started using C++11 or C++14 features and this requires a newer compiler.
> Can you try with the latest Visual Studio?
>
>
>
> I don't have anything installed, and I kinda liked the idea of only having
> an SDK.
> I'm not big on C++ or Visual Studios, so I'm not sure what to install. VS
> 2015 SP2 Enterprise? Is there a free version?
> Or is there maybe a bare minimum command-line package this would work on?
>
>
> The wiki is outdated and I can change it but I'm not sure why new users
> can't or why the email/password reset system is broken. I can check it out
> later.
>
>
> It seems to be working for me now.
>
> ---=---
> Александр
>
>
> --
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Issue #1573: interrupt a tight loop

2016-05-26 Thread Björn Lindqvist
Hello,

You could certainly wrap the CreateThread function and call it from
factor. See the windows.kernel32 vocab for how wrapping Windows system
functions are done. On the VM:s level, threads are started with the
start_thread() function which is defined in vm/os-windows.cpp. Oh, and
didn't we discuss this issue last year?
https://sourceforge.net/p/factor/mailman/message/34507872/



2016-05-26 21:33 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello again!
>
>   To fix https://github.com/factor/factor/issues/1573 I need to know one 
> thing: can I start a native thread (WinAPI CreateThread) within the 
> Factor.exe process with Factor code running in it? If so, how do I do it?
>
>   If not, I'll have to implement it in VM's C++ code.
>
> ---=---
>  Александр
>
> --
> Mobile security can be enabling, not merely restricting. Employees who
> bring their own devices (BYOD) to work are irked by the imposition of MDM
> restrictions. Mobile Device Manager Plus allows you to control only the
> apps on BYO-devices by containerizing them, leaving personal data untouched!
> https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Complex Shuffle Words

2016-05-04 Thread Björn Lindqvist
2016-05-04 22:20 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>   I have a question: but won't using lexical variables make the code fatter? 
> Are there any optimizations that would make the code that uses lexical 
> variables as optimal as the code that manipulates the stack directly? Because 
> I saw disassembly of what the rot word does, and it's pretty damn optimal. If 
> I do the same with lexical variables, will it be as optimal?
>
>   I guess what I'm trying to ask is this: lexical variables do make the code 
> more readable, but does that come with a performance price or not?

Since you always have the compiler and disassembler at hand in Factor,
you can easily check for yourself if using locals make any difference.
Using locals could possibly add a few extra MOV instructions if you
are using a lot of them. But these MOV instructions are incredibly
cheap so it makes no difference at all. I would be very surprised if
you were able to demonstrate a measurable speedup by replacing locals
with stack shuffling words.


-- 
mvh/best regards Björn Lindqvist

--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Listener on Windows - UI Corruption

2016-04-30 Thread Björn Lindqvist
>   Having said all that, I suspect GC to be the source of problems. Did any of 
> you experience similar issues on other platforms besides Windows?
>   How do I go about hunting for that kind of bug in Factor?

You can never exclude anything, but it seems very unlikely that the GC
would be the problem. The GC copies objects so it is vulnerable to
shadow data bugs. That is, some references might no be updated to
point to the newly copied to location for the object. In the listener,
you can run the minor-gc and gc words and see if there is a pattern or
if you are able to trigger the bug that way. You can also recompile
Factor to run in debug mode:

  nmake /f Nmakefile x86-64 DEBUG=1

Also I see that you are running Factor in compatibility mode because
the fonts are all blurry. That is automatically enabled in Windows for
Factor if you have a high dpi screen. You can try and disable it by
right-clicking the .exe file and go: Properties -> Compatibility ->
Inactivate scaling when using High DPI.


-- 
mvh/best regards Björn Lindqvist

--
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] How would I solve this better in Factor?

2016-03-12 Thread Björn Lindqvist
Here is my solution:

https://github.com/bjourne/playground-factor/blob/master/examples/golf/challenge-252/challenge-252.factor

It's a straight transliteration of the Python solution that was posted
in the reddit thread. The hard part was getting the loops right.
Factor doesn't have any iteration syntax so you have to use
combinators and recursion instead. The trickiest word to translate was
widest_leftmost_pair because it uses many variables and mutable state.
The body of the function is the loop in "for i, ch in enumerate(s)"
and it corresponds to Factors each-index combinator.

When I wrote the code, I used the locals vocab and lexical variables
almost everywhere. Because if you are not sure how the data should
flow through your words it is easier to first get something ugly
working with locals, then when you have it working you can easily
rewrite it in the stack-oriented style. It helps to write tests so
that you don't break your code while refactoring. Some words, like the
update-pair word, can't or shouldn't be translated to stack-oriented
style because juggling five data items on the stack gets confusing.

2016-02-24 5:50 GMT+01:00 Sankaranarayanan Viswanathan
<rationalrev...@gmail.com>:
> Hi,
>
> It had been awhile since I wrote any Factor code, so I was trying to
> solve the following problem from reddit's dailyprogrammer subreddit:
> http://bit.ly/1OtP8Qj
>
> The solution I came up with in Factor looks like this:
> http://bit.ly/1PY8j98
>
> I struggled quite a lot coming up with this. Mainly in keeping things in
> my head and figuring out what I needed to do to bring the stack in order
> for the operations I was attempting..
>
> Coming from an iterative programming background (with a little bit of
> exposure to functional programming), I find it quite hard to formulate
> solutions in Factor. Can someone help me with tips on how they approach
> writing code in Factor? What is your though process to turn a given
> pseudo code into a factor program?
>
> For example, my pseudo code for the main portion of this problem (the
> find-match function) was as follows:
>
> let buff = ""
> let match = (indx=0, length=-1)
> for each char c in input:
> find count(c) in buff
> if count == 2
> append c to buff
> check if str(first c to end) is longest and update match
> remove chars in buff before second c occurrence
> else if count == 1
> append c to buff
> check if str(first c to end) is longest and update match
> remove chars in buff before first c occurrence
> else
> append c to buff
> discard buff and return match
>
> Any pointers is greatly appreciated.
>
> Thanks,
> Sankar
>
>
> --
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151=/4140
> _______
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111=/4140
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] images: new words to handle sprites and extract parts of an image

2015-11-30 Thread Björn Lindqvist
Perhaps you can add it to some of the vocabs in the images.*
hierarchy? I think images.tesselation or images.processing would be
suitable. Also see the tesselate word, if I'm not mistaken it does the
same thing as your generate-sprite-sheet word. But there is nothing
like your image-part and new-image-like words afaict, so those would
be useful. But maybe you should rename image-part to crop-image?
Cutting a smaller image from an existing one is a cropping operation.

> For a small game that I was making in order to get accustomed to factor,
> I needed to load textures from a sprite sheet. Basically, I wanted to
> take an image and split it into pieces of fixed dimensions. I wasn't
> able to find words to help me there (may be there are and I am unaware).
> So I ended up introducing a few new words:
>
> new-image-like: create a new empty image having properties of an
> existing image but with modified dimensions
>
> image-part: extract a part of an image into a separate image
>
> generate-sprite-sheet: given an image, produce a sequence of images
> having fixed width and heights
>
> These new words can be seen implemented here:
> https://github.com/rationalrevolt/factor-practice/blob/master/images/sprites/sprites.factor
>
> A small test program using these words is present here:
> https://github.com/rationalrevolt/factor-practice/blob/master/sprite-test/sprite-test.factor
>
> If these are useful, could someone recommend a vocabulary that could
> contain them? The words new-image-like and image-part could reside in
> the images vocab. I'm not sure where the generate-sprite-sheet word
> could fit in or if it is sufficiently useful to include.



-- 
mvh/best regards Björn Lindqvist

--
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911=/4140
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Ctrl+Break

2015-10-12 Thread Björn Lindqvist
2015-10-01 23:12 GMT+02:00 Alexander Ilin <ajs...@yandex.ru>:
> Hello!
>
> 01.10.2015, 22:33, "HP wei" <hpwe...@gmail.com>:
>> I try to hit Control-C but it continues to run.
>> *** How to exit a running words ?
>
>   HP wei raises a very good point. Is there a way to interrupt an
>   infinite loop or a long-running word?

Yep. Ctrl+C is supposed to always interrupt the currently running thread.

>   If such a mechanism is not there in Factor UI, I could share a way
>   to implement it (Windows-specific).
>
>   It involves running a native background thread with the Ctrl+Break
>   hotkey globally hooked. When the hotkey is triggered, the main
>   thread is interrupted by setting its exception flag. All words
>   running from the Scratchpad should expect this special kind of
>   exception. I'm not too good with Factor yet, so I could not
>   implement this without some serious help/pointers, but I can share
>   the details of the same mechanism implemented elsewhere (an
>   open-source run-time environment).

It works already, mostly. Roughly in the same way as you are describing
it.

On windows, there is code in vm/os-windows.cpp that sets the consoles
ctrl key handler. So when ctrl+c is pressed, it enqueues a
safepoint. Meaning that it sets the write protection on a memory
segment. Threads periodically (like once per loop iteration) write to
that segment which causes segfaults which is how they are stopped. The
details are in vm/safepoints.cpp.

Then Factor brings up a very simple CLI in which the VM state can be
inspected and the threads continued. It is implemented in
factor_vm::factorbug() in vm/debug.cpp.

But the Console Ctrl Handler is only for the console. So when ctrl+c is
pressed in the GUI it is not even heard by the system. So no safepoint
is enqueued and no threads are ever stopped. I'd be happy to hear if you
know of a way to send ctrl+c to a GUI program but I don't think there is
one. The situation is the same on Linux. On the console, ctrl+c
generates a SIGINT signal but not when the GUI is run.

Running a Factor thread in the background that listens for ctrl+c won't
do much good unfortunately because Factor's threading is cooperative and
not preemptive. So, if you run a busy loop such as [ t ] [ ] while, then
that thread will starve out all others. When we get preemptive
multitasking, aka kernel threads, into Factor this problem would be
trivial to fix but right now it is very hard.


--
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] potential memory issue

2015-10-12 Thread Björn Lindqvist
2015-10-02 20:12 GMT+02:00 HP wei <hpwe...@gmail.com>:
> First,
> In factor's listener terminal (not in the gui window, though),
> Jon Harper suggested to hit Control-C and t to terminate
> a long running code.
> I hit Control-C in below case (1), it brings out a low level debugger (what
> a pleasant surprise).
>
> Let me ask a question first before I write more about investigating the
> issue.
> *** in the low-level debugger, one of the commands is 'data' to dump data
> heap.
>  Is there any way to dump the result to a file ??

No. But you can easily log the console output:

./factor -run=readline-listener |& tee -i out.log


> Summary of further investigation.
>
> The code
> 0 "a_path_to_big_folder" x [ link-info dup symbolic-link? [ drop ] [ size>>
> + ] if  ] each-file

I believe this code is a rough example on how to do it. To count disk
usage in a real Linux directory tree is much more involved than
that. You need to account for hard links, virtual file systems, volatile
files and much more. Look at all switches "man du" lists -- it is
complicated.


> (1) when x = t  (breadth-first  BFS)
>  the memory usage reported by linux's  'top' shows steady increase
>  from around 190M to as high as 2GB before either I killed it or it hit
> tge
>  missing file issue.

I don't think you are hitting a missing file issue. In
/proc//fd there is an extra ephemeral file which shows up
because listing the contents of a directory requires opening a file
which creates a file descriptor. You can trigger the same problem in
Python using:

[os.stat(f) for f in os.listdir('/proc/%d/fd' % os.getpid())]


>   But the total-file-size of about 280GB is incorrect.  It should be
> around 74GB.

This could be because the size of /proc files are counted. Especially
the /proc/kcore file is enormous.


> For the above disk,  DFS appears to consume much less memory !
> But the resulting file size is incorrect (280GB instead of 70GB).
> This is presumably due to (NOTE-A) and the code must have scanned through
> those
> OTHER disks.  But then the extra scanning appears to be incomplete!

It's hard to say what might be up. But if the disks are mounted under
the directory you supplied to each-file, then the files on those disks
will be counted.

> In closing,  the simple code (with DFS)
> 0 "a_path_to_big_folder" f [ link-info dup symbolic-link? [ drop ] [
> size>> + ] if  ] each-file
> could NOT achieve the intended action --- to sum up the file-size for files
> residing in a
> disk (as pointed to by a_path_to_big_folder).

That is not surprising. Here is a better method to do it:

USING: accessors combinators.short-circuit continuations
io.directories.search io.files.info io.files.types kernel math
math.order namespaces sets ;

! Filter hardlinks
SYMBOL: seen-inos

: regular-file-size ( file-info -- s )
! In case it's one of the fake huge /proc files
[ size>> ] [ size-on-disk>> ] bi min ;

: count-file-info? ( link -- s )
{
[ type>> +regular-file+ = ]
[
{ [ nlink>> 1 = ] [ ino>> seen-inos get ?adjoin ] } 1||
]
} 1&& ;

: file-info-size ( link -- s )
dup count-file-info? [ regular-file-size ] [ drop 0 ] if ;

: file-size ( path -- s )
[ link-info file-info-size ] [ 2drop 0 ] recover ;

: du-tree ( path -- s )
HS{ } clone seen-inos set
0 swap t [ file-size + ] each-file ;

It gives a decent disk usage counts for me. It underreports the total in
comparison with "du -s --si" because I excluded directory sizes.


--
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A bug ?

2015-10-01 Thread Björn Lindqvist
2015-10-01 8:47 GMT+02:00 HP Wei <hpwe...@gmail.com>:
> Thanks for suggesting to look at the source of (directory-entries)
>
> I see that the iterator over a directory is the word: with-unix-directory
> and (directory-entries) uses produce to collect the entries into a sequence.
>
> I did not find a word in sequences that is similar to produce but does a
> ‘reduce’ action
> — sot that I could simply replace ‘produce’ in the definition of
> (directory-entries).

You can do it like this:

USING: accessors alien.strings classes.struct combinators
continuations io.backend io.directories.unix io.files.info kernel math
sequences unix.ffi ;
FROM: io.directories.unix.linux => next-dirent ;
IN: examples.sequences

DEFER: directory-size

: entry-size-file ( name -- size )
file-info size>> ;

: entry-size-dir ( name -- size )
dup { "." ".." } member? [ drop 0 ] [
normalize-path directory-size
] if ;

: entry-size ( dirent* -- size )
[ d_name>> alien>native-string ] [ d_type>> ] bi {
{ DT_REG [ entry-size-file ] }
{ DT_DIR [ entry-size-dir ] }
[ 2drop 0 ]
} case ;

: dirent-size ( unix-dir dirent -- size/f )
next-dirent [ entry-size ] [ drop f ] if ;

: (directory-size) ( unix-dir dirent -- total )
2dup dirent-size [ -rot (directory-size) + ] [ 2drop 0 ] if* ;

: directory-size ( path -- total )
[
[ dirent  (directory-size) ] with-unix-directory
] [ 2drop 0 ] recover ;

The code gets a little tricky because you didn't want to ever load a
full directory listing into memory.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] how to run-pipeline

2015-09-24 Thread Björn Lindqvist
2015-09-23 5:46 GMT+02:00 HP Wei <hpwe...@gmail.com>:
> My original issue was to construct the string “cmd1 -a A -b B” and “cmd2 -c
> C”
> in a flexible way so that I can choose to supply (or not supply) those
> argument A, B, C.
> And find a clean way to put everything together into { … } for run-pipeline.

Maybe with some helper words:

: render-command ( cmd args -- string )
[ dup array? [ " " join ] when ] map " " join " " glue ;

: make-pipeline ( seq -- seq' )
[ first2 render-command ] map ;

:: special-pipeline ( a-arg b-arg -- pipeline )
a-arg "def-a" or :> real-a
b-arg "def-b" or :> real-b
{ { "ls" { } } { "grep" { { "-a" real-a } { "-b" real-b } "--verbose" } } }
make-pipeline ;

Or simpler:

: special-pipeline ( a-arg b-arg -- pipeline )
[ "def-a" or ] [ "def-b" or ] bi* "grep -a %s -b %s" sprintf
"ls" swap 2array ;

IN: scratchpad f f special-pipeline
{ "ls" "grep -a def-a -b def-b" }

Factor doesn't have words with variable number of arguments, so you
supply f instead and then the default is picked.


-- 
mvh/best regards Björn Lindqvist

--
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991=/4140
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Does the location of the image file matter ?

2015-07-29 Thread Björn Lindqvist
It's because the switch is -resource-path not just -resource.

2015-07-29 9:11 GMT+02:00 Georg Simon georg.si...@auge.de:
 Am Tue, 28 Jul 2015 23:41:59 +0200
 schrieb Björn Lindqvist bjou...@gmail.com:

 I'm not sure I understand you. By default, resource: is setup as an
 alias the the directory containing the image file. But you can
 override it:

 factor -resource-path=/bla/bla -i=factor.image

 Essentially, resource: is just a convenient alias and you are free
 to put your vocab roots anywhere on the filesystem. For example, you
 could add . first on the vocab roots and then you'd have a vocab
 lookup similar to how Python looks up modules.

 It's about the existing vocabularies. They seem to disappear when I use
 an image file located elsewhere. Without vocabularies the listener
 crashes too. So I wrote a script scratchVocabulary.factor:
 -
 USING:
 io io.backend io.pathnames prettyprint
 ;
  resource: prepend-path normalize-path . flush
  vocab: prepend-path normalize-path . flush
 -
 With this script I can see that vocab: is affected by the location of
 the image file:
 -
 $ cp /home/pub/factor/factor.image .

 $ factor-lang scratchVocabulary.factor
 /home/pub/factor/
 /home/pub/factor/core

 $ factor-lang -i=factor.image scratchVocabulary.factor
 /home/factor/scratchVocabulary/
 /home/factor
 -
 The reason seems to be the value of vocab-roots:
 V{
 resource:core
 resource:basis
 resource:extra
 resource:work
 }
 So that seems to be intended and I have to live with it.

 Now I also tried overriding as you suggested. No effect:
 -
 $ factor-lang -resource=/home/pub/factor -i=factor.image \
 scratchVocabulary.factor
 /home/factor/scratchVocabulary/
 /home/factor
 -
 In addition I could not find any documentation about the command line
 switch -resource.

 --

 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] stack effect

2015-07-29 Thread Björn Lindqvist
Georg solved your problem, but in the future you can easily use
Factors introspection to see why it complains about stack effects. For
example, the first quotation given to the inner if is [ 0 ] and you
can infer its stack effect:

IN: scratchpad [ 0 ] infer.
( -- x )

Then because the two quotations given to if must have the same stack
effect, the second quotation must also have ( -- x ) which you can
check like this:

! Needs to be declared because you are using locals
IN: scratchpad SYMBOLS: amount coins cc denominations ;
IN: scratchpad [ amount coins 1 - cc amount coins denominations at*
drop - coins cc + ] infer.
( -- x x x x x )

Or you can manually count the stack delta. Local variables and numbers
are +1, binary operations and drop -1 and at* is +/- 0:
  +1 +1+1 -1 +1 +1 +1+10   -1   -1 +1+1 -1
[ amount coins 1  -  cc amount coins denominations at* drop -  coins cc +  ]

1 + 1 + 1 - 1 + 1 + 1 + 1 + 1 + 0 - 1 - 1 + 1 + 1 - 1 = +5

2015-07-29 9:44 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 why do I get the following error?

 Stack effect declaration is wrong
 inferred ( x x x -- x x )
 declared ( amount coins -- ways )

 from this lexical variable

 :: cc ( amount coins -- ways )
 0 amount = [ 1 ]
 [ 0  amount 0 coins = or [ 0 ]
   [ amount coins 1 - cc
 amount coins denominations at* drop - coins cc + ]
   if ]
   if ;

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Does the location of the image file matter ?

2015-07-28 Thread Björn Lindqvist
I'm not sure I understand you. By default, resource: is setup as an
alias the the directory containing the image file. But you can
override it:

factor -resource-path=/bla/bla -i=factor.image

Essentially, resource: is just a convenient alias and you are free
to put your vocab roots anywhere on the filesystem. For example, you
could add . first on the vocab roots and then you'd have a vocab
lookup similar to how Python looks up modules.

2015-07-27 8:46 GMT+02:00 Georg Simon georg.si...@auge.de:
 Am Sun, 26 Jul 2015 12:35:01 +0200
 schrieb Georg Simon georg.si...@auge.de:

 Yes, it does matter.

 http://docs.factorcode.org/content/article-io.pathnames.special.html
 
 If a pathname begins with resource:, it is resolved relative to the
 directory containing the current image (see image-path).

 If a pathname begins with vocab:, then it will be searched for in all
 current vocabulary roots (see Working with code outside of the Factor
 source
 tree).
 
 IN: scratchpad vocab-roots get .
 V{
 resource:core
 resource:basis
 resource:extra
 resource:work
 /home/factor
 }
 
 The location of the image file affects resource: and resource:
 affects vocab:

 So I now know that I have to keep all image files in the same directory?

 -- Georg

 --

 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Does the location of the image file matter ?

2015-07-26 Thread Björn Lindqvist
Judging by the binary name factor-lang you have the factor package
installed from my ppa. But it appears that you have a fresher image
coming from github. You probably can't mix the two versions like that.
You can try and run:

resource:db absolute-path

in the listener. It should show you a directory containing the
db.factor file. If it doesn't something is wrong. Also swap the order
of the command line arguments, it should be:
-i=/home/pub/factor/project.image -run=project.

2015-07-26 12:35 GMT+02:00 Georg Simon georg.si...@auge.de:
 Factor 0.98 x86.64 (1565, heads/master-0-g592764d, Wed Dec 24 04:52:05
 2014) [GCC 4.8.2] on linux

 .factor-rc
 
 USE: vocabs.loader
 /home/factor/ add-vocab-root
 

 I want to use snapshots without touching factor.image.

 I made two copies of factor.image one in the same directory and one
 in my local directory. Using the copy in my local directory causes an
 error Vocabulary does not exist.

 In the following copy from my terminal the vocabulary project seems
 to do nothing as it's UI worked as expected:
 
 $ diff /home/pub/factor/project.image project.image
 $ factor-lang -run=project -i=/home/pub/factor/project.image
 $ factor-lang -run=project -i=project.image
 /home/factor/project/project.factor

  9: USING:
 10: combinators db db.sqlite fry io kernel memory models
   ^
 Vocabulary does not exist
 name
  db
 

 How should I use snapshots?

 -- Georg

 --

 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] What do we call a collection of vocabs?

2015-07-09 Thread Björn Lindqvist
There is a correspondence between common languages names for
programming objects and Forth-inspired languages names:

Python   = Java   = Factor
function = method word
module   = class  vocabulary
package  = package???

So in Python, a collection of functions (and classes) in a file forms
a module and a collection of modules forms a package. In Java, a
collection of methods forms a class and a collection of classes forms
a package. In Factor, a file with words is a vocab but a collection of
vocabs is what? :) Do we have a name for it?


-- 
mvh/best regards Björn Lindqvist

--
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] FreeBSD 10 amd64 supported?

2015-07-09 Thread Björn Lindqvist
Are you able to build the factor binary? That's the first step. It's
hard to see in the diff in your repo what could be wrong. You could
try adding:

#define __linux__ 1

to the top of platform.hpp and then run make linux-x86-64 or make
linux-x86-32, depending on your cpu arch. That should give you a
runnable factor binary. There are a few steps after that too, but it
is easiest to learn the process one step at a time.

2015-07-09 11:53 GMT+02:00 Dave Cottlehuber d...@skunkwerks.at:
 Hi,

 I'm new to factor  forthy languages.

 I forked [1]  started looking at building factor on FreeBSD 10.1 amd64,
 but ran into some trouble compiling. I made some changes[2] but
 ultimately got lost in the makefile stuff. Is anybody more familiar with
 how this should work? This seems like it's almost there: [3].

 GIT_URL=git://github.com/dch/factor.git ./build-support/factor.sh update
 | tee /ramdisk/factor-build-FreeBSD-10.1-amd64.log | dpaste

 [1]: http://github.com/dch/factor
 [2]: https://github.com/dch/factor/commit/faacbb5
 [3]: https://dpaste.de/tRb9

 --
 Don't Limit Your Business. Reach for the Cloud.
 GigeNET's Cloud Solutions provide you with the tools and support that
 you need to offload your IT needs and focus on growing your business.
 Configured For All Businesses. Start Your Cloud Today.
 https://www.gigenetcloud.com/
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] nested nil lists

2015-07-03 Thread Björn Lindqvist
Maybe you already know, but factor doesn't use lists in the same
capacity as scheme and other lisp-variants. Instead it uses sequences.
So to construct a one-item sequence where the first element is f (~=
nil):

IN: scratchpad f 1array

Or just use a literal:

IN: scratchpad { f }

2015-07-03 11:14 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 in Scheme I can evaluate (list ‘()) to get ‘(())
 as a nested null list

 Factor supplies nil (+nil+) but I can’t seem to get the above using cons, 
 1list etc.
 is this not the natural way to do this in Factor?
 --
 Don't Limit Your Business. Reach for the Cloud.
 GigeNET's Cloud Solutions provide you with the tools and support that
 you need to offload your IT needs and focus on growing your business.
 Configured For All Businesses. Start Your Cloud Today.
 https://www.gigenetcloud.com/
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] displaying Lisp like nested lists

2015-06-29 Thread Björn Lindqvist
In addition to the other suggestions, maybe you really want swons?

IN: scratchpad nil 77 swons 10 swons 20 swons listarray .
{ 20 10 77 }

2015-06-29 14:37 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 I make a list with

 1 nil cons 2 nil cons nil cons nil cons

 but listarray displays only top level, can it descend recursively?

 --
 Monitor 25 network devices or servers for free with OpManager!
 OpManager is web-based network management software that monitors
 network devices and physical  virtual servers, alerts via email  sms
 for fault. Monitor 25 devices for free with no restriction. Download now
 http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical  virtual servers, alerts via email  sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] osx emacs FUEL

2015-06-01 Thread Björn Lindqvist
You shouldn't need to set emacs-path if the emacs and emacsclient
binaries are on your path. emacsclient is not called correctly from
Factor, but as a workaround you can start the server manually. First
start emacs and in it type M-x server-start. Then you should be able
to run io edit in the Factor gui and have the file shown in emacs.

2015-06-01 10:54 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 I have setup the file .factor-boot-rc as

 USING: editors.emacs namespaces ;
 “/Applications/languages” \ emacs-path sett-global

 which sets up the path to emacs.app
 running factor.app I get on doing “palindrome” edit

 error code 1 which seems to be complaining about “emacsclient”

 whereas loading palindrome.factor into emacs and typing meta-x run-factor I 
 get a syntax aware editor
 and a factor listener

 What am I missing?

 Thanks, Iain

 p.s. original bounced as I included screen captures


 On 31 May 2015, at 00:11, Björn Lindqvist bjou...@gmail.com wrote:

 Could you explain in more detail what your problem is?

 2015-05-30 19:04 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 I have successfully integrated FUEL in emacs but cannot seem get it 
 integrated with Factor. My emacs is 24..4.1 and an aoo and my os is OS X 
 10.3. Any advice appreciated. Iain
 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



 --
 mvh/best regards Björn Lindqvist

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk


 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] osx emacs FUEL

2015-05-30 Thread Björn Lindqvist
Could you explain in more detail what your problem is?

2015-05-30 19:04 GMT+02:00 Iain Gray iaing...@ednet.co.uk:
 I have successfully integrated FUEL in emacs but cannot seem get it 
 integrated with Factor. My emacs is 24..4.1 and an aoo and my os is OS X 
 10.3. Any advice appreciated. Iain
 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] LLVM - ASM.js

2015-03-27 Thread Björn Lindqvist
I don't think so. Factor already has an optimizing compiler so llvm isn't
needed. Someone could theoretically write a backend to it to emit asm.js
javascript code instead of x86 32  64 bit assembler code that it does
today.

2015-03-23 11:46 GMT+00:00 Henri Morlaye henri.morl...@gmail.com:

 Hi,

 Has anyone ever explored compiling to asm.js, possibly via llvm ?

 Henri
 ᐧ


 --
 Dive into the World of Parallel Programming The Go Parallel Website,
 sponsored
 by Intel and developed in partnership with Slashdot Media, is your hub for
 all
 things parallel software development, from weekly thought leadership blogs
 to
 news, videos, case studies, tutorials and more. Take a look and join the
 conversation now. http://goparallel.sourceforge.net/
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Debugging words with locals

2015-02-04 Thread Björn Lindqvist
Hi Benjamin,

The reason for that is because the local variables are syntactic sugar
over the load/drop/get-locals calls you are seeing. E.g:

IN: scratchpad [| x y | y sq x + ] .
[ 2 load-locals 0 get-local sq -1 get-local 2 drop-locals + ]

It is similar to how fry quotations are sugar over curry and compose:

IN: scratchpad [ 123 '[ 4 _ * ] ]  .
[ 123 [ [ 4 ] ] dip [ * ] curry compose ]

See also: https://github.com/slavapestov/factor/issues/758

I'm unsure of how the walker works, but I think it instruments the
code it tries to walk and then compiles it with the non-optimizing
compiler. So the quotation is executed verbatim which makes it easy to
know where the current execution point is. But locals and fry
quotations (and all kinds of optimizations for that matter) are
destructive one-way operations so you can't reconstruct the original
source code from the result.

I believe the general way to solve the problem is source maps -- You
include the original source of the word when debugging and then for
each stepping point in the words quotation, you map to a line number
and char position in the source code. ergs parser branch could make
adding such features easier.

2015-01-31 23:18 GMT+00:00 Benjamin Pollack benja...@bitquabit.com:
 The walker makes debugging words with locals a bit of a pain; you get a
 bunch of calls to load-locals/drop-locals/get-local/etc., rather than the
 actual variable names.  Assuming I'm not missing something about how to
 configure the walker to deal with this, where would I want to look to try
 improving things?


-- 
mvh/best regards Björn Lindqvist

--
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A performance challenge

2015-01-25 Thread Björn Lindqvist
2015-01-18 2:44 GMT+00:00 John Benediktsson mrj...@gmail.com:
 Also, minor comment, instead of:

 length [ 0 ] { } replicate-as ;

 You can just do:

 length 0 array

Thanks!

 And instead of the array-nth stuff, you can just do some type declarations
 and the compiler should make it the same as your array words:

 { fixnum array } declare nth-unsafe ;

 { array } declare first2-unsafe ;

Oh of course. When I wrote the code I was trying to stay stay close to
the metal and tell Factor exactly what code it should generate. Even
if it figures it out equally well on its own anyway.

 I recommend using TYPED: or TYPED:: declarations to specify neighbors is an
 array and normal sequence words?

I was trying that, but Factor appears to add dynamic type checks to
words which call typed words which increase the size of the generated
code.


-- 
mvh/best regards Björn Lindqvist

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] A performance challenge

2015-01-17 Thread Björn Lindqvist
Hello all,

Someone made a benchmark on github to compare performance of different
languages on a simple pathfinding problem:

https://github.com/logicchains/LPATHBench/blob/master/writeup.md

It's getting popular and people are quoting the results they get from
it to show that a language is really fast. Factor wasn't represented
to I wrote an implementation of the algorithm here:

https://github.com/bjourne/playground-factor/blob/master/lpath/lpath.factor

Performance is pretty good I think. Factor runs in ~1340 ms while the
Java version runs in ~1030 ms on my machine. And it wasn't that hard
to get that speed -- you just replace safe generic words like nth with
unsafe specialized ones like array-nth. Though I wonder if anyone has
any ideas on how to make the Factor code run even faster?

One idea I toyed with was making a non-recursive variant of the
(longest-path) word. Right now it is co-recursive, (longest-path)
calls ((longest-path)) which calls (longest-path). I think that if you
can get rid of the co-recursion it would easily become as fast as the
Java version.


-- 
mvh/best regards Björn Lindqvist

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Google+ Factor community and first question

2015-01-17 Thread Björn Lindqvist
Great initiative, I subscribed!

2015-01-16 9:46 GMT+00:00 Marc Hanisch marc.hani...@googlemail.com:
 Hell list,

 I've discovered Factor some days ago and am really impressed! On the search
 for more information I couldn't believe that there is no community / forum /
 whatever - except this mailinglist - where users can exchange. So I've
 created a Google+ community for the Factor programming language. I don't
 include a link here, please search for Factor Language in Google+ and you
 will find it. I would be glad if some users join.


-- 
mvh/best regards Björn Lindqvist

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Standalone executables in Windows

2015-01-07 Thread Björn Lindqvist
Hi John,

Last I tried which was a while ago, deploying executables on Windows
worked fine. Doesn't it anymore? See
http://docs.factorcode.org/content/article-tools.deploy.usage.html for
docs.

2015-01-07 13:10 GMT+01:00 John Sampson jrs@ntlworld.com:
 In 2007 there was a thread on this subject. Daniel Ehrenberg gave a link
 to a factorcode.org faq page, but this is now broken (404 error).

 It was stated that a tool for making standalone executables was in
 development - is it in existence?

 Regards

 John Sampson


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A stub of a package manager

2014-12-18 Thread Björn Lindqvist
Great work Andrea!

Factor needs a package management system eventually. Programmers have
this strange infatuation with packages and unless the language offers
it, it's just not taken seriously. Maybe because people are customed
to the language core being almost closed and the bar uber high for
contributions so people feel they need to release their own packages
to contribute.

I think Factor's community is more open than that and John and Doug
are amazingly responsive on the bug tracker. So if you have any
worthwhile code to contribute, just make a pull request and it will be
merged quickly. Then you'll get code maintenance for free in case the
language changes and your test suite is setup to run nightly which
catches bugs.

So I tried to get your package manager to work, but something goes wrong:

USE: packages.example
example-project activate
Added packages.projects vocabulary to search path
More than one file found for vocabulary: example-project

Type :help for debugging help.

Maybe the code is in flux? Anyway, here are some random thoughts about
your implementation:

* You can't have one voacb root per package. If you run threads. in
  the listener, you'll see that there is one thread for each of the
  three roots. They monitor that directory tree and reloads vocabs
  that change automatically. See
  http://docs.factorcode.org/content/article-vocabs.refresh.html So
  yes, there are performance problems.

* So for example, to install your monoid package, I run:

$ git clone https://github.com/andreaferretti/factor-monoid
$ cp -r factor-monoid/monoid /opt/factor64/lib/factor/extra

  (Thats where my resources:extra is) And in the listener:

IN: scratchpad USE: monoid
IN: scratchpad 3 3 |+| .
6

  No need to restart Factor or any other setup to get it
  going. Suppose then you released a new version of monoid, I would
  copy it to /opt/factor64/lib/factor/extra and then simply run:

IN: scratchpad refresh-all
Loading resource:extra/monoid/monoid.factor

  Factor would then recompile your monoid vocab and not only that, all
  vocabs I have loaded that uses monoid would automatically be
  recompiled too.

  Uninstallation is a sore point though and that's where I think a
  package managerwould really shine.

* Maybe we can repurpouse resource:extra as the package installation
  url? In a way it already is. Or we could add a specific
  resource:packages root.

* I like that the configuration is Factor code, but I think you went
  to syntax happy. :) A simple assoc would suffice:

{
{ project example-project }
{ url https://github.com/andreaferretti/factor-example.git; }
{ version 0.1.0 }
{ dependencies {
https://github.com/andreaferretti/factor-packages.git;
https://github.com/andreaferretti/factor-options.git;
} }
}

  Also the standard convention is to have metadata inside the
  vocabulary's own directory. So why not have it in say
  monoid/monoid-pkg.factor? It would be symmetrical with the
  -docs.factor and -tests.factor suffixes.

* You might also want to look into Factor's application deployment
  system: http://docs.factorcode.org/content/article-tools.deploy.html
  because deployment has many similarities with making packages. Also
  see the summary.txt, authors.txt, deploy.factor and tags.txt
  files. Possibly they could all be merged into one
  vocabname-meta.factor file?

* I realised you've spent a lot of thought thinking about how
  dependencies and especially transitive dependencies should
  work. Personally, I think it's way, way, to soon to think about that
  and a package manager that just handled the packaging and not any
  deps would still be really useful.

* Feel free to ignore all my points above. :) It's ofcourse better if
  a package manager is created than that bikeshedding prevents it from
  ever happening.



-- 
mvh/best regards Björn Lindqvist

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2014-11-29 Thread Björn Lindqvist
Yes! Now there's a Utopic package there too.

2014-11-26 12:00 GMT+01:00 Andrea Ferretti ferrettiand...@gmail.com:
 Would it be possible to add a package for Ubuntu 14.10?

 2014-11-25 19:39 GMT+01:00 John Porubek jporu...@gmail.com:
 On Sat, Nov 22, 2014 at 11:35 AM, Björn Lindqvist bjou...@gmail.com wrote:

 I have just now created new packages for Ubuntu trusty and precise,
 based on the git version, which you can download from the same place
 as below. It's not a release version, but it works well enough for me.
 Just remember that you need to type factor-lang to run factor.


 This just showed up in Update Manager on my Ubuntu 12.04 LTS system and
 installed without a hitch. I especially appreciate that it shows the version
 info. in both the gui and console invocations.

 Thanks Björn for your efforts in creating this.

 -John

 --
 Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
 from Actuate! Instantly Supercharge Your Business Reports and Dashboards
 with Interactivity, Sharing, Native Excel Exports, App Integration  more
 Get technology previously reserved for billion-dollar corporations, FREE
 http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk


 --
 Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
 from Actuate! Instantly Supercharge Your Business Reports and Dashboards
 with Interactivity, Sharing, Native Excel Exports, App Integration  more
 Get technology previously reserved for billion-dollar corporations, FREE
 http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2014-11-22 Thread Björn Lindqvist
I have just now created new packages for Ubuntu trusty and precise,
based on the git version, which you can download from the same place
as below. It's not a release version, but it works well enough for me.
Just remember that you need to type factor-lang to run factor.

2013-08-26 9:45 GMT+02:00 Björn Lindqvist bjou...@gmail.com:
 Hello!

 I've created a PPA and made an experimental Factor package for Ubuntu:

 https://launchpad.net/~bjourne/+archive/factor

 The binary name factor was already taken by a program in coreutils
 so I had to change it to factor-run. Please beta test and tell me if
 the package doesn't work. :)


 --
 mvh/best regards Björn Lindqvist
 http://www.bjornlindqvist.se/



-- 
mvh/best regards Björn Lindqvist

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor 0.97 now available

2014-11-05 Thread Björn Lindqvist
Yeah that's probably needed.

2014-11-05 16:35 GMT+01:00 John Benediktsson mrj...@gmail.com:
 Hmm, maybe we should revert back to requiring development libraries for now,
 and do a 0.97.1 release.

 On Wed, Nov 5, 2014 at 1:07 AM, Andrea Ferretti ferrettiand...@gmail.com
 wrote:

 It works for me too. Any chance this fix will be deployed in the
 official download? It is unforunate that the default download does not
 work out of the box on recent Ubuntus, as it may hinder adoption

 2014-11-04 19:12 GMT+01:00 mr wzrd wzr...@gmail.com:
 
  On 11/04/2014 01:02 PM, Björn Lindqvist wrote:
  You and mr wzrd, run this in a terminal:
 
   $ ./factor -run=listener
   IN: scratchpad gtk.ffi reload
   IN: scratchpad save
 
  Then Factors GUI should start. I've written an explanation of the bug
  here: https://github.com/slavapestov/factor/issues/1185
 
 
  Works.  Nice job!
 
 - mrw
 
 
 
  --
  ___
  Factor-talk mailing list
  Factor-talk@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/factor-talk


 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



 --

 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor 0.97 now available

2014-11-04 Thread Björn Lindqvist
Could you (and mr wzrd) run:

/sbin/ldconfig -p | grep gtk

and paste the output of that command? And also can you paste the exact
error message you get when you run ./factor?


2014-11-04 12:20 GMT+01:00 Andrea Ferretti ferrettiand...@gmail.com:
 By the way, I have the same issue as mr wzrd - on Ubuntu 14.04 64bit
 desktop edition. I *do* have a libgtk-x11-2.0.so.0, but it is under
 /usr/lib/x86_64-linux-gnu/

 2014-11-04 10:06 GMT+01:00 Andrea Ferretti ferrettiand...@gmail.com:
 Congratulations for the great work!

 I would be glad to see a 1.0 release, if anything just for
 psychological reasons when I show Factor to my colleagues :-)

 Are there any plans to move the distribution to a model with a core +
 a package manager? I think at this point it would benefit the
 community if there was an official way to provide new libraries
 without being involved in the core. Package managers for image-based
 languages are slightly delicate, but I think the model used by
 Monticello+Metacello in the Smallatlk community works pretty well.

 Best,
 Andrea

 2014-11-03 13:27 GMT+01:00 John Benediktsson mrj...@gmail.com:
 We've been brainstorming a few things. Not sure how much of it will be done 
 and in what order, but some of the features I'd like us to work on:

 - new parser to allow parsing cross-platform vocabularies without loading 
 them and development of useful refactoring tools

 - improve compiler for performance of fixnums, loops, and generic dispatch, 
 possibly leveraging LLVM

 - faster namespace variables (which are used in a lot of places) using a 
 different lookup algorithm

 - unification of core and basis to allow using higher level language 
 features earlier in the bootstrap process

 And more vocabularies and libraries, etc. Plus we love contributions so if 
 anyone else has some ideas here, we'd love to hear.

 Best,
 John.


 On Nov 3, 2014, at 3:23 AM, Björn Lindqvist bjou...@gmail.com wrote:

 Hurra!

 Any plans for 0.98 or, dare I say it, 1.0? Factor feels like a very
 solid language to me and it's just lacking in polish.


 --
 mvh/best regards Björn Lindqvist

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor 0.97 now available

2014-11-04 Thread Björn Lindqvist
 Factor
 should work out of the box on recent Ubuntus

 2014-11-04 15:45 GMT+01:00 Björn Lindqvist bjou...@gmail.com:
 Could you (and mr wzrd) run:

 /sbin/ldconfig -p | grep gtk

 and paste the output of that command? And also can you paste the exact
 error message you get when you run ./factor?


 2014-11-04 12:20 GMT+01:00 Andrea Ferretti ferrettiand...@gmail.com:
 By the way, I have the same issue as mr wzrd - on Ubuntu 14.04 64bit
 desktop edition. I *do* have a libgtk-x11-2.0.so.0, but it is under
 /usr/lib/x86_64-linux-gnu/

 2014-11-04 10:06 GMT+01:00 Andrea Ferretti ferrettiand...@gmail.com:
 Congratulations for the great work!

 I would be glad to see a 1.0 release, if anything just for
 psychological reasons when I show Factor to my colleagues :-)

 Are there any plans to move the distribution to a model with a core +
 a package manager? I think at this point it would benefit the
 community if there was an official way to provide new libraries
 without being involved in the core. Package managers for image-based
 languages are slightly delicate, but I think the model used by
 Monticello+Metacello in the Smallatlk community works pretty well.

 Best,
 Andrea

 2014-11-03 13:27 GMT+01:00 John Benediktsson mrj...@gmail.com:
 We've been brainstorming a few things. Not sure how much of it will be 
 done and in what order, but some of the features I'd like us to work on:

 - new parser to allow parsing cross-platform vocabularies without loading 
 them and development of useful refactoring tools

 - improve compiler for performance of fixnums, loops, and generic 
 dispatch, possibly leveraging LLVM

 - faster namespace variables (which are used in a lot of places) using a 
 different lookup algorithm

 - unification of core and basis to allow using higher level language 
 features earlier in the bootstrap process

 And more vocabularies and libraries, etc. Plus we love contributions so 
 if anyone else has some ideas here, we'd love to hear.

 Best,
 John.


 On Nov 3, 2014, at 3:23 AM, Björn Lindqvist bjou...@gmail.com wrote:

 Hurra!

 Any plans for 0.98 or, dare I say it, 1.0? Factor feels like a very
 solid language to me and it's just lacking in polish.


 --
 mvh/best regards Björn Lindqvist

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



 --
 mvh/best regards Björn Lindqvist

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk

 --
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor 0.97 now available

2014-11-03 Thread Björn Lindqvist
Hurra!

Any plans for 0.98 or, dare I say it, 1.0? Factor feels like a very
solid language to me and it's just lacking in polish.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Multithreading in Factor

2014-10-15 Thread Björn Lindqvist
Hi Andrea,

I'm not an expert, so take what's written below with a grain of
salt. It mostly comes from what I've snapped up from varius places and
reading the mailing list archive (eg
http://search.gmane.org/?query=threadinggroup=comp.lang.factor.generalsort=relevance).

2014-10-13 18:14 GMT+02:00 Andrea Ferretti ferrettiand...@gmail.com:
 Hi, I have read in various places, including this mailing list, that
 Factor does not currently have support for (preemptive, kernel-level)
 multithreading, and that adding support for that would require a great
 deal of changes, since the underlying VM and many core words are not
 thread-safe.

It's true that Factor doesn't have preemptive, kernel-level threading
(I'll just write threading from now on when I refer to this
particular brand of threading) and that adding it would probably
require a lot of engineering and restructuring work. But if you dig
into the source, and read the previous discussions, it's clear that
adding threading was always the idea and the Factor VM has been
architected to make it simple to add in the future.

Whether it actually is simple or not, is a different matter. But it's
much different from, say, the CPython VM which is implemented in such
a way that it would be virtually impossible to add threading.

Most composite (non-primitive) words are thread-safe and the primitive
words are only thread-unsafe in that critical sections aren't
guarded by exclusion locks.

 Can anyone expand on this? Is there some place where people have
 collected some ideas about the issues that would arise and the areas
 that need work?

I don't think there is any particularly bloody issues. It's just a lot
of hard work.

For example interactions between threads and gc can be very tricky. If
two threads need to allocate memory, there needs to be some
synchronization so that they don't end up pointing to the same chunk
of memory. How do you make that both fast and safe?

What happens with a threads object references if another thread forces
a gc cycle? I guess all threads has to stop running during the gc so
that all object references can be updated. It's even more complicated
if one thread is in an ffi function which holds a pointer to a Factor
object.

What if another thread recompiles the same word a thread is running?

 If not, it would be nice to gather such information from people
 knowledgeable about the internals of factor, so that interested people
 could start make some contributions.

 I don't know if personally I would be able to contribute, but I'd love
 to if I I found something I could handle

An alien wrapper for pthreads would be interesting. I've no idea if it
would kind of work or break Factor badly, non-the-less it would be
interesting to see.

While we're at the subject of threading.. It's a great feature but a
language VM can do without it and still be very useful. Python,
Erlang, Node.js and Ruby all proves that. If the goal of the
concurrency is IO throughput, then cooperative threads which Factor
already has works really well. For cpu intensive tasks you can often
start multiple processes instead of threading.



--
mvh/best regards Björn Lindqvist

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Let's fix yosefk's tricky code

2014-08-14 Thread Björn Lindqvist
2014-08-14 0:17 GMT+02:00 Jon Purdy evincarofaut...@gmail.com:
 Sigh. The formatting button in Gmail is directly next to the “Send” button.
 Apologies, list.


 It seems like most of the overhead comes from fixed-point arithmetic,
 actually. Here’s a translation to Kitten with locals:

 def meanStd (float float float → float float):

   → sum2 sum invLen;

   sum ×. invLen → μ;
   μ (sum2 ×. invLen −. μ square) sqrt

 You can write this in postfix:

 def meanStd (float float float → float float):

   → sum2 sum invLen;

   sum invLen (×.) → μ;
   μ sum2 invLen (×.) μ square (−.) sqrt

 Then easily eliminate μ:

 def meanStd (float float float → float float):

   → sum2 sum invLen;

   sum invLen (×.) dup
   { sum2 invLen (×.) } dip
   square (−.) sqrt

Interesting! But what does the (x.) and (-.) words do?


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Let's fix yosefk's tricky code

2014-08-14 Thread Björn Lindqvist
2014-08-14 9:44 GMT+02:00 Jon Purdy evincarofaut...@gmail.com:
 Interesting! But what does the (x.) and (-.) words do?

 Multiply and subtract in floating point. Factor obviates such
 distinctions with dynamic typing.

Now I get it. With locals your code translates to this in Factor:

:: mean-std-2 ( sum^2 sum inv-len -- mean std )
sum inv-len * dup [ sum^2 inv-len * ] dip sq - sqrt ;

Or without locals:

: mean-std-8 ( inv-len sum^2 sum -- mean std )
pick * -rot * over sq - sqrt ;

Here I rearranged the parameter order to make the stack shuffling more
convenient. Another variant using the tuck word:

: mean-std-6 ( sum^2 sum inv-len -- mean std )
tuck * -rot * over sq - sqrt ;

I must say that the algorithm makes a compelling argument in favor of
locals! Or perhaps in favor of rearranging the parameters to fit the
problem better:

! Fry and tuck
: mean-std-10 ( sum^2 sum inv-len -- std mean )
'[ _ * ] bi@ tuck sq - sqrt ;

I think the last one is fairly readable.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Let's fix yosefk's tricky code

2014-08-13 Thread Björn Lindqvist
Hello everybody,

Here is an interesting blog post from yosefk about Forth and stack machines:

http://yosefk.com/blog/my-history-with-forth-stack-machines.html

It contains a lot of interesting stuff but one part in particular got
my interest. He is trying to write a word to compute the mean and the
standard deviation of a vector given the sum of its elements, the sum
of their squares, and the inverse of its length and what he produces
to solve it is:

: mean_std ( sum2 sum inv_len -- mean std )
  \ precise_mean = sum * inv_len;
  tuck u* \ sum2 inv_len precise_mean
  \ mean = precise_mean  FRAC;
  dup FRAC rshift -rot3 \ mean sum2 inv_len precise_mean
  \ var = (((unsigned long long)sum2 * inv_len)  FRAC) -
(precise_mean * precise_mean  (FRAC*2));
  dup um* nip FRAC 2 * 32 - rshift -rot \ mean precise_mean^2 sum2 inv_len
  um* 32 FRAC - lshift swap FRAC rshift or \ mean precise_mean^2 sum*inv_len
  swap - isqrt \ mean std ;

So his code is hideous and I'm wondering if we can do it better in
Factor? I'd love to take a stab at it myself but I have no idea what
mathematical formula he is implementing. Anyone knows? As far as I
understand, given three scalar values: the sum of all elements in a
vector, the sum of all elements squared and the inverse of the length,
you should be able to calculate the mean of the vector and the
standard deviation.


-- 
mvh/best regards Björn Lindqvist

--
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] What exactly is the retain stack?

2014-05-16 Thread Björn Lindqvist
2014-05-16 0:29 GMT+02:00 Jon Purdy evincarofaut...@gmail.com:
 Is that it's only use? Then why? dip can easily be formulated using
 non-retain stack using primitives:

 For example: a b c [ append ] dip - a b c -rot append swap


 That implementation assumes the quotation takes two operands and
 produces one result, which is not always the case. More generally, the
 functional argument of “dip” is not really supposed to be able to
 touch the argument it’s operating under. If you don’t have types or a
 stack checker enforcing this, the formulations with a retain stack or
 dynamically composing quotations are safe by construction, but the
 “-rot” version is not. Consider “[ 3drop ] dip” or “[ append dup ]
 dip”.

But factor *does* have a stack checker. Since the stack effect of the
quotation given to dip can be inferred, you can always (I think?)
rewrite them using nothing but normal stack shuffling operations. Like
so:

: make-shuffle-effect ( n dir -- effect )
swap 1 + iota swap dupd rotated [ array ] bi@ effect ;

: emit-dip ( quot -- )
dup infer
[ nip in length -1 make-shuffle-effect , \ shuffle-effect , ]
[ swap , , \ call-effect , ]
[ nip out length 1 make-shuffle-effect , \ shuffle-effect , ] 2tri ;

: rewrite-dip ( quot -- quot' )
first2 drop [ emit-dip ] [ ] make ;

[ [ append over ] dip ] rewrite-dip will output the quotation:

[
( 0 1 2 3 -- 3 0 1 2 ) shuffle-effect
[ append over ] ( x x x -- x x x ) call-effect
( 0 1 2 3 -- 1 2 3 0 ) shuffle-effect
]

Now neither shuffle-effect nor call-effect are Factor primitives but
they easily could have been and then dip would only need to touch the
data stack.


-- 
mvh/best regards Björn Lindqvist

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] What exactly is the retain stack?

2014-05-15 Thread Björn Lindqvist
Hi everyone,

I've been walking around in Factors VM for a while and there is a lot
of usages and references to the retain stack. But I can't for my
life figure out what its purpose is or why anyone ever would want one
when there is a perfectly good data stack already available.

I only found these two posts by Slava Pestov about it:

http://article.gmane.org/gmane.comp.lang.factor.general/1931/match=retain+stack
http://factor-language.blogspot.se/2010/07/overhauling-factors-c-library-interface.html

In the future, I intend on using GC maps at call sites of Factor
words as well, instead of spilling temporary values to the retain
stack; then I can eliminate the retain stack altogether, freeing up a
register. After this is done the data stack will only be used to pass
parameters between words, and not to store temporaries within a word.
This will allow more values to be unboxed in more situations, and it
will improve accuracy of compiler analyses.

So the retain stack is useless? Freeing up a whole register sounds
like it should be great for performance, at least on 32 bit x86.


-- 
mvh/best regards Björn Lindqvist

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] What exactly is the retain stack?

2014-05-15 Thread Björn Lindqvist
Hi!

Is that it's only use? Then why? dip can easily be formulated using
non-retain stack using primitives:

For example: a b c [ append ] dip - a b c -rot append swap


2014-05-15 22:49 GMT+02:00 Slava Pestov sl...@factorcode.org:
 Hi Bjorn,

 The retain stack is used to implement the 'dip' combinator.

 Slava


 On Thu, May 15, 2014 at 1:46 PM, Björn Lindqvist bjou...@gmail.com wrote:

 Hi everyone,

 I've been walking around in Factors VM for a while and there is a lot
 of usages and references to the retain stack. But I can't for my
 life figure out what its purpose is or why anyone ever would want one
 when there is a perfectly good data stack already available.

 I only found these two posts by Slava Pestov about it:


 http://article.gmane.org/gmane.comp.lang.factor.general/1931/match=retain+stack

 http://factor-language.blogspot.se/2010/07/overhauling-factors-c-library-interface.html

 In the future, I intend on using GC maps at call sites of Factor
 words as well, instead of spilling temporary values to the retain
 stack; then I can eliminate the retain stack altogether, freeing up a
 register. After this is done the data stack will only be used to pass
 parameters between words, and not to store temporaries within a word.
 This will allow more values to be unboxed in more situations, and it
 will improve accuracy of compiler analyses.

 So the retain stack is useless? Freeing up a whole register sounds
 like it should be great for performance, at least on 32 bit x86.


 --
 mvh/best regards Björn Lindqvist


 --
 Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
 Instantly run your Selenium tests across 300+ browser/OS combos.
 Get unparalleled scalability from the best Selenium testing platform
 available
 Simple to use. Nothing to install. Get started now for free.
 http://p.sf.net/sfu/SauceLabs
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk



 --
 Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
 Instantly run your Selenium tests across 300+ browser/OS combos.
 Get unparalleled scalability from the best Selenium testing platform
 available
 Simple to use. Nothing to install. Get started now for free.
 http://p.sf.net/sfu/SauceLabs
 ___
 Factor-talk mailing list
 Factor-talk@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/factor-talk




-- 
mvh/best regards Björn Lindqvist

--
Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free.
http://p.sf.net/sfu/SauceLabs
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] manual memory management and STRUCT:

2014-03-18 Thread Björn Lindqvist
Hi Jon,

2014-03-17 21:57 GMT+01:00 Jon Harper jon.harpe...@gmail.com:
 Hi list,
 I am working with libyaml, a C library to parse yaml docs. Some libyaml
 functions give string results by malloc'ing memory and giving back pointers
 to those strings in a struct. They then require the caller to call a libyaml
 destroy function on the struct that frees the strings.

 I would like to make a deep copy of the manually managed struct to a garbage
 collected struct so that I can keep some data after I called the libyaml
 destroy function and not worry about freeing it. Does anyone know how to do
 this simply ?

Let me preface this by saying that I'm far from an expert neither on
libyaml or factor... But this is what I think I've figured out about
how alien memory management works.

What I think you are doing wrong is worrying to much about freeing the
memory you are allocating. The ?scalar-value word is only an
intermediate step in the doc parsing process. Since the yaml words
body already is wrapped in a with-destructors block, and it is the
main entry point for your parser, you don't need to call
with-destructors anywhere else.

Just remember to pair every allocation (or resource acquisition) with a
destructor word (which you already are doing) and factor should work
it out fine.


--
mvh/best regards Björn Lindqvist

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] manual memory management and STRUCT:

2014-03-18 Thread Björn Lindqvist
2014-03-18 14:12 GMT+01:00 Jon Harper jon.harpe...@gmail.com:
 In this case, it's more complicated then a single with-destructor scope,
 because I use the destructors to call libyaml's destroy function on the
 struct, so that the same memory can be reused between the calls to libyaml
 for this struct. So I really need to destroy it right away before the next
 call the libyaml, hence the nested with-destructors.

 I could allocate new memory for those structs every time and destroy them
 only at the end of the parsing. But in most cases, only one struct is needed
 at a given time, so I thought reusing them was a good thing.
 Jon

I think you're falling for the premature optimization trap
here. Allocating memory is incredibly cheap so unless your code is
memory constrained there is no need to save on it. It's always better to
start with the simplest implementation you can get away with and then
if you run into performance problems start to optimize it.


--
mvh/best regards Björn Lindqvist

--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] installation packages for CI?

2014-02-27 Thread Björn Lindqvist
2014-02-10 6:56 GMT+01:00 Andrew Pennebaker andrew.penneba...@gmail.com:
 I can add that ppa to my source list, but when I `apt-get install factor`, I
 get a program for factoring compound numbers, not the Factor programming
 language.

 Could we rename the ppa to work around the name collision?

No you do get the Factor language. But the binary is called
factor-lang not factor which is a number factoring program shipped
with coreutils. Btw you may also wish to uninstall and reinstall
factor as I've recently published new packages here:

https://launchpad.net/~bjourne/+archive/factor

I plan to update them frequently to keep them in sync with Factor's
main master branch.


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis  security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] How to reload help definitions?

2014-02-13 Thread Björn Lindqvist
2014-02-13 17:45 GMT+01:00 Jean-Marc Lugrin hb9...@lugrin.ch:
 It may be due to the fact that I copied the executable and images from the
 latest development release (2013-04-26) over the sources of the master on
 github, as I have no way to rebuild the current version on windows.
 Probably in some cases this creates some problems.

When you upgrade in that fashion you need to run refresh-all save in
Factor. Otherwise your image will not contain the latest changes from
git.


-- 
mvh/best regards Björn Lindqvist

--
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Best way to split a fixed locations

2014-02-09 Thread Björn Lindqvist
2014-02-09 14:41 GMT+01:00 Jean-Marc Lugrin hb9...@lugrin.ch:
 Hi,
 I need to split a string at fixed locations (some of the locations may
 eventully be calculated, like with a lookup of '/', but at first
 approximation fixed locations are ok).

 I came with this example string and quotatiom:

 NAXIS   =3 / number of data axes
 
 [  0 swap 8 swap subseq ] [ 10 swap 30 swap subseq ] [ 33 swap 80 swap
 subseq ] tri [ [ 32 = ] trim ] tri@

Some more variants for you to consider:

Using fry:

: subseqs ( indices seq -- subseqs )
'[ first2 _ subseq [ blank? ] trim ] map ;

Using with:

: subseqs ( seq indices -- subseqs )
[ first2 rot subseq [ blank? ] trim ] with map ;

Also Jon's idea of finding higher-level splitting words to work with
is really good. E.g.

IN: NAXIS   =3 / number of data axes
IN: /= split [ [ blank? ] trim ] map .
{ NAXIS 3 number of data axes }


-- 
mvh/best regards Björn Lindqvist

--
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] installation packages for CI?

2014-02-09 Thread Björn Lindqvist
2014-02-08 11:56 GMT+01:00 Gabriel Kerneis gabr...@kerneis.info:
 On Fri, Feb 07, 2014 at 06:44:32PM -0500, Andrew Pennebaker wrote:
 If we met users half way, presenting .deb's, .rpm's, maybe a ppa repo, that
 would be a great start.

 As a first step, I recommend using https://build.opensuse.org/

 It is slightly openSUSE centered, but makes it easy to check that your
 basic rpm  deb build for ubuntu, debian, fedora and openSUSE.

A while ago I created Ubuntu packages for Factor and put them in my
PPA here: https://launchpad.net/~bjourne/+archive/factor

Someone has also packaged Factor for Arch:
https://aur.archlinux.org/packages/factor/

A big problem is that Factors build doesn't make it easy to install
system-wide in a typical Linux setup. So you have to add lots of hacks
to the build to add support for prefixed installation, with binary and
support files split in different directories. It's a lot of work and
hard to keep it in sync with Factors github repository. A smaller
problem is that some Factor words wants to overwrite the image and
file and write in directories relative to the executable file which
obviously is problematic on Linux where writes outside of $HOME is
forbidden. But I think most Linux users can live with that limitation.

So to address the problematic build I've created an alternate build
process which you are welcome to check out here:
https://github.com/slavapestov/factor/pull/934 It's written using waf
which I think is great for complicated build-processes like Factor's.
With the branch, the build command becomes python waf.py configure
--prefix=/opt/factor2 build  sudo python waf.py install. Using that
as their base, I believe someone knowledgable of their distro's build
system could very easily package Factor.

Then to actually get distros to put Factor in their repos would entail
reopening tickets like this:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=471925 Plus, Debian
has some bureaucratic rules on packages they ship. Like requiring a
man page.


-- 
mvh/best regards Björn Lindqvist

--
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Presentation and installation issues on Slackware64-14.1 Linux

2013-12-11 Thread Björn Lindqvist
Hi Luis,

2013/12/10 Luis P. Mendes luisl...@gmail.com:
 Here are some benchmarks (posted by the author of Factor?) comparing
 Factor against V8, LuaJIT, SBCL, and CPython:

 http://factor-language.blogspot.com/2010/05/comparing-factors-performance-against.html
 http://shootout.alioth.debian.org/ contains more benchmarks for more
 programming languages(including C++).

 I know about http://shootout.alioth.debian.org/, but Factor is not one
 of the languages being compared.

I believe Factor does very well in various benchmarks. Factor code is
not run inside of a VM, like Python or Java (which has a JIT, yes) and
is instead compiled to native machine code so it has the potential to be
very fast.

But it really isn't that important. Factor's Alien library makes it very
easy to write cross-platform wrappers for shared libraries. It's
analoguous to ctypes in Python but better. So in a large project it
would be trivial to write the most performance intensive functions in C
and the rest of the application in Factor.

Factor already comes with a wrapper for BLAS if you need fast numerical
computation, for example.

 After some more digging into the language, Factor does really feel
 like a very good language.  But after some more searching, in
 http://planet.factorcode.org/  and the blogs pointed there, I come to
 realize that it seems that developers don't earn their living using
 Factor, except maybe for Slava Pestov.  There are some C++, Java, and
 some discussions about incursions in other languages like Self.
 So, my question is this:  is Factor really meant to be used in real
 world business applications? Do developers and main contributors
 really believe in this possibility?

I'm just a Factor newbie, but sure why not? Right now, not many people
use Factor because it is not marketed much and it still has some minor
blemishes. Many people like functional programming which Factor excels
at so I think it would be possible that more people will become
interested in it.


--
mvh/best regards Björn Lindqvist

--
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET,  PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor interface to Spotlight

2013-11-13 Thread Björn Lindqvist
Here are some random tips from me. I'm also a Factor newbie so take it
with a grain of salt:

 * Don't use vectors because normal sequences works just as well.
 * Be functional! Avoid words that mutate data structures because they
make the code harder to reason about.

F.e. this piece of code in mdls:

mdls 1vector swap suffix!

can be written as just:

mdls swap 2array

Another example is your mdutil word:

:: (mdutil) ( flags on|off volume root/owner -- seq )
root/owner 1vector - flags append suffix!
-i suffix! on|off suffix! volume suffix!

It's a great showcase for local variables but can be better written
without array mutations:

:: mdutil ( flags on|off volume root/owner -- seq )
root/owner flags - prepend -i on|off volume 5 narray


2013/11/13 CW Alston cwalsto...@gmail.com:
  I've posted a new gist for spotlight.factor w/ filename  Factor
 formatting.
 I think I dealt with most of Alex's red-lines,  I shed the string
 constants.
 The whole thing is much shorter. The included examples work on my machine.

  The file can be USE:d from the listener if you give it a folder in your
 'work'.

  After a long divagation, looks like I've wound up back where John  Alex
 suggested I start, 3 weeks ago. Well, like I was warned in the Boy Scouts,
 when you wander lost in the woods, you tend to go 'round in circles.
 Just couldn't see how to get on from there without a compass (or native
 guides),
  I did learn a lot along the way. Still needs some improvement (maybe bug
 fixes, too).

  In particular, I'd like to memoize an API call to
 MDSchemaCopyAllAttributes(),
 but I'm better at Chinese than C. Pointers on alien-invoke, or what else to
 use?



-- 
mvh/best regards Björn Lindqvist

--
DreamFactory - Open Source REST  JSON Services for HTML5  Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] process command conundrum

2013-10-21 Thread Björn Lindqvist
2013/10/21 CW Alston cwalsto...@gmail.com:
 :: mdfind-request ( filename -- seq )
  'kMDItemFSName ==  filename tri-quotes-surround append  '
 append ;

 : mdfind-process ( filename -- process )
  mdfind-request! ( -- seq )
  '[ mdfind , -onlyin , / , _ ,  ,
 /Users/cwalston/factor/mdfind.txt , ]
  { } make  ! ( -- seq )
   process swap command
   t detached clone  ! ( -- process )
 ;

 And then, Finding Joy in Combinators.pdf mdfind-process contains a
 command
 sequence that looks like this:
 {
 mdfind
 -onlyin
 /
 'kMDItemFSName == \Finding Joy in Combinators.pdf\'
 
 /Users/cwalston/factor/mdfind.txt
 }

The command attribute in process should be a string not a sequence
of strings. I think that is the core of your problem, not sure. Also,
input and output redirection is a feature of the shell, not the os, so
you need to wrap those commands in a subshell. But that is platform
dependent since not all shells are available everywhere and they dont
all have the same features. Here is how you could write a find utility
for Windows (using gnu find), maybe you can use it as a template:

USING: formatting io.launcher kernel ;
IN: cmdpipe

CONSTANT: find-bin C:\\Program Files (x86)\\Git\\bin\\find.exe

: shell-command ( str -- str' )
cmd /C \%s\ sprintf ;

: find-command ( dir pattern out-path -- str )
[ find-bin ] 3dip \%s\ \%s\ -name \%s\  \%s\ sprintf ;

: run-find ( dir pattern out-path -- proc )
find-command shell-command run-process ;

IN: scratchpad C:\\Users\\bjourne\\Downloads *.pdf
C:\\Users\\bjourne\\result.txt run-find


-- 
mvh/best regards Björn Lindqvist

--
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register 
http://pubads.g.doubleclick.net/gampad/clk?id=60135031iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2013-09-03 Thread Björn Lindqvist
2013/9/2 Marek Kubica ma...@xivilization.net:
 On Mon, 26 Aug 2013 20:59:45 +0200
 Björn Lindqvist bjou...@gmail.com wrote:

 That should work. But you shouldn't have to have the image file in a
 writable directory unless you wish to save the state of a listener
 session. On Linux, it's most common to have all user writable files
 under /home/username/ and not let the user write to other files
 (except for /tmp) on the system.

 You could also check out the Arch Linux AUR package:
 https://aur.archlinux.org/packages/factor/. We also have a .desktop
 file and the binary is called factor-vm. It would be good if the
 binary had the same name everywhere.

Thanks. I didn't know someone else had already packaged Factor for any
platform. I'll be sure to check it out and change the binary name in
my packages.


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2013-08-28 Thread Björn Lindqvist
Rupert Swarbrick skrev 2013-08-27 11:20:
 Björn Lindqvist bjou...@gmail.com
 writes:
 2013/8/26 Alex Vondrak ajvond...@gmail.com:
 On Mon, Aug 26, 2013 at 12:45 AM, Björn Lindqvist 
 bjourne-re5jqeeqqe8avxtiumw...@public.gmane.org wrote:
 The binary name factor was already taken by a program in coreutils
 so I had to change it to factor-run.

 How about something like factor-lang or factor-listener?

 I actually called the binary factor-lang. But then I needed a
 factor-run bash script too because Factor isn't happy with having the
 standard library in a different directory from the binary file.

 The obvious thing to do, which I think is the standard approach for
 packaging such programs, is the following. Just install Factor, with the
 binary called factor, into some directory in /usr/share. For example,
 /usr/share/factor would be fine. Then create a symlink or a shell script
 in /usr/bin pointing to /usr/share/factor, which is called factor-lang
 or whatever.

Interesting! I thought putting binaries outside of bin directories were 
heavily discouraged. Which is why I choose to rename it. Do you have an 
example of a package that follows the approach you are suggesting? Then 
I could just copy that.

--
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Factor packaging for Ubuntu

2013-08-26 Thread Björn Lindqvist
Hello!

I've created a PPA and made an experimental Factor package for Ubuntu:

https://launchpad.net/~bjourne/+archive/factor

The binary name factor was already taken by a program in coreutils
so I had to change it to factor-run. Please beta test and tell me if
the package doesn't work. :)


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2013-08-26 Thread Björn Lindqvist
2013/8/26 Georg Simon georg.si...@auge.de:
 I've created a PPA and made an experimental Factor package for Ubuntu:

 https://launchpad.net/~bjourne/+archive/factor

 I am not sure if it is a good solution but I configured as follows:

 I made a new directory where I have writing rights without being root.
 I copied /usr/lib/factor/factor.image into the new directory.
 I made a subdirectory work/ in there.
 I added 2 lines to my ~/.factor-rc:
  USE: vocabs.loader
  /opt/pub/mDS/factor/work/ add-vocab-root
 I call factor-run with my copy of factor.image:
  factor-run -i=/opt/pub/mDS/factor/factor.image
 I have to use scaffold-vocab instead of scaffold-work.

That should work. But you shouldn't have to have the image file in a
writable directory unless you wish to save the state of a listener
session. On Linux, it's most common to have all user writable files
under /home/username/ and not let the user write to other files
(except for /tmp) on the system.


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Factor packaging for Ubuntu

2013-08-26 Thread Björn Lindqvist
2013/8/26 Alex Vondrak ajvond...@gmail.com:
 On Mon, Aug 26, 2013 at 12:45 AM, Björn Lindqvist bjou...@gmail.com wrote:
 The binary name factor was already taken by a program in coreutils
 so I had to change it to factor-run.

 How about something like factor-lang or factor-listener?

I actually called the binary factor-lang. But then I needed a
factor-run bash script too because Factor isn't happy with having the
standard library in a different directory from the binary file.


-- 
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Indentation width and other style guidelines

2013-07-21 Thread Björn Lindqvist
Hi all factorians!

I noticed the default indentation width recently changed in fuel-mode
from 4 to 2 spaces. Does that mean the recommended indentation is now
2? In general, does Factor have any established style guidelines
analogous to, say PEP 8 (http://www.python.org/dev/peps/pep-0008/) for
Python? I often struggle with figuring out the most readable way to
split long expressions into multiple lines.


--
mvh/best regards Björn Lindqvist
http://www.bjornlindqvist.se/

--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Using find-by-class in html.parser.analyzer

2013-07-15 Thread Björn Lindqvist
2013/7/15 Alex Vondrak ajvond...@gmail.com


 In general, I'm not sure if html.parser is very mature compared to, say,
 the XML vocab: http://docs.factorcode.org/content/article-xml.html


The major difference is that html.parser handles invalid html which the xml
vocab doesn't.  So for parsing pages on the web, html.parser is what you
have to use. Would be great if someone wrote a wrapper for libxml2 which is
the best xml/html parsing library ever. Then you wouldn't need to use
different interfaces for xml and html.


--
mvh Björn
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] A Factor tutorial

2013-07-09 Thread Björn Lindqvist
Hi John,

Thanks for the great feedback!

2013/6/24 John Benediktsson mrj...@gmail.com
 I believe vprintf and vsprintf are now available in formatting
 vocabulary, so you wouldn't need to duplicate that functionality if a
 user has a recent developer version of Factor.  The original macro
 version of printf is still useful because it can expands the format
 string at parse time.

Oh, I didn't know that. Does the Windows prebuilt development releases
include those features? They are dated April 26 and April 24, so I
assume they aren't. But it would be very nice if they where updated. :)
It is so difficult to compile source on Windows so you can't expect most
users to be able to do it, like you can on Linux.

 For simple text data, you can use strings.tables to format it
 (automatically makes the columns as wide as necessary for the data),
 or if you want to apply styles (colors, fonts etc) to the text you can
 use tabular-output or stream-write-table.  Your version with
 fixed-width columns and table headers for strings might be a nice
 addition to strings.tables if you want to factor it out.

I tried format-table in strings.tables first, but quickly discarded the
idea because it left-aligns all columns. Numeric cell data should almost
always be right-aligned even if the header looks best when centered or
left-aligned. I think it would be hard to integrate what I've written
with what exists there but I can try.

 I'm not sure it is good practice to shadow a core word such as read,
 although one could argue that it makes your interface simpler and a user
 would be unlikely to confuse the two.  But maybe 10 post would be a
 better name to get them and 10 post. would be a better name to get and
 print (using our dot convention for words that write/print text).

I didn't know that was a convention! Is there any page in the manual for
special characters? ? obviously indicates a boolean predicate but
what about the other characters? Would word be a setter for example?

For example, I've tried implementing state using the namespaces vocab
(which I'm not at all sure is right) and setter and getter words named
set-pagesize and get-pagesize. But I thought long and hard whether
set-pagesize should be called pagesize and get-pagesize
pagesize instead.

 Are you interested in contributing this to the main repository?  It's a
 pretty neat vocabulary and a great example / tutorial for our users.

Thanks! I'll do that when I consider the code done - it's definitely a
work in progress still.


--
mvh Björn Lindqvist
--
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831iu=/4140/ostg.clktrk___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


  1   2   >