From: Alexandre E. Kopilovitch aek@vib.usr.pu.ru
Subject: limbo
Date: Tue, 23 Jul 1996 18:34:28 +0400 [thread overview]
Message-ID: <19960723143428.Vp1Rr7eYwDUbgHPgtS7nIZTYZyWd86TIvrTEWgrbWmo@z> (raw)
howard@plan9.BEll-labs.COM (Howard Trickey) writes:
>> would it be possible to implement a qsort replacement in limbo ?
>
>It is possible, but the answer is so ugly that the real answer is "no".
>
>(The caller could pass in a channel, and then be willing to answer
>questions like "is element 5 greater than element 3" over the channel;
>the answer could be an array of element indices in their sort order. Channels
>of ascii can be a universal way around type checking.)
>
>So, for instance, there is a module for sorting directory entries (in various
>ways), but no general purpose sorting module.
This answer seems rather strange to me, I think that Limbo already has
sufficient features for implementing general sorting module.
General sorting module (let's call it Sort) needs two external functions:
one to compare elements of array (taking two integer indices and producing
integer -1/0/+1 result) and another - to exchange them (again, taking their
integer indices).
Indeed, the question is how to give Sort access to user-supplied Compare
and Exchange functions. It can be done as follows: the user must supply
*implementation* of module which has a fixed name, say, Sort_User and the
fixed declaration:
Sort_User module {
Sort_Compare: fn (first_index: int, second_index: int) : int;
Sort_Exchange: fn (first_index: int, second_index: int);
};
I see no obstacles for user-supplied implementation of Sort_User module
to access an array to be sorted.
Then, one of the arguments for the actual sorting functions of the Sort
module must be *path* from which these functions should *load* proper
Sort_User implementation. So, Sort module can call user-supplied Sort_Compare
and Sort_Exchange functions because:
1) the name of Sort_User module is fixed
2) the path to Sort_User module is known to the Sort when it is called
3) the declaration of Sort_User module is fixed and contains declarations of
functions Sort_Compare and Sort_Exchange.
Alexander Kopilovitch aek@vib.usr.pu.ru
Saint-Petersburg
Russia
next reply other threads:[~1996-07-23 14:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-23 14:34 Alexandre [this message]
-- strict thread matches above, loose matches on Subject: below --
1996-08-02 15:32 limbo ^*_*^
1996-08-02 15:32 limbo ^*_*^
1996-07-19 20:43 limbo philw
1996-07-19 20:11 limbo Balaji
1996-07-18 12:09 limbo Howard
1996-07-18 10:38 limbo Roger
1996-07-18 3:28 limbo Rogers
1996-07-17 23:56 limbo philw
1996-07-17 23:29 limbo Shon
1996-07-17 15:39 limbo Roger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19960723143428.Vp1Rr7eYwDUbgHPgtS7nIZTYZyWd86TIvrTEWgrbWmo@z \
--to=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).