unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* idea: create module
@ 2006-04-25  1:31 Jon Wilson
  2006-04-25  7:09 ` Thien-Thi Nguyen
  2006-04-25 23:05 ` Neil Jerram
  0 siblings, 2 replies; 6+ messages in thread
From: Jon Wilson @ 2006-04-25  1:31 UTC (permalink / raw)


Hi all,
I just had a random idea, and thought I'd run it by y'all.  What if you
could compose modules from the REPL, and then write them to a file? 
Something like:

(define mod (make-module (my modulename)))
(define f1 (lambda () (display "f1")))
(define value 7)
(add-export mod f1 value)
(write-module-file "my_modulename.scm")

With my luck, something like this probably already exists and I'm just
too stupid to have found it, but I think it would make module writing
easier.

Perhaps also you could load an existing module, and then make
modifications to it, and then write it to a file as well.

Thoughts?
Regards,
Jon
-- 
  Jon Wilson
  j85wilson@fastmail.fm

-- 
http://www.fastmail.fm - Email service worth paying for. Try it for free



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: idea: create module
  2006-04-25  1:31 idea: create module Jon Wilson
@ 2006-04-25  7:09 ` Thien-Thi Nguyen
  2006-04-25 23:05 ` Neil Jerram
  1 sibling, 0 replies; 6+ messages in thread
From: Thien-Thi Nguyen @ 2006-04-25  7:09 UTC (permalink / raw)
  Cc: guile-user

   From: "Jon Wilson" <j85wilson@fastmail.fm>
   Date: Mon, 24 Apr 2006 18:31:55 -0700

   (define mod (make-module (my modulename)))
   (define f1 (lambda () (display "f1")))
   (define value 7)
   (add-export mod f1 value)
   (write-module-file "my_modulename.scm")

you can use `define-module' in a repl.  run the repl in an emacs buffer
and it's a SMOP to filter out prompts and output on `C-x C-w' (to start,
see `write-contents-hooks' and friends).

thi


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: idea: create module
  2006-04-25  1:31 idea: create module Jon Wilson
  2006-04-25  7:09 ` Thien-Thi Nguyen
@ 2006-04-25 23:05 ` Neil Jerram
  2006-04-26 13:51   ` Jon Wilson
  1 sibling, 1 reply; 6+ messages in thread
From: Neil Jerram @ 2006-04-25 23:05 UTC (permalink / raw)
  Cc: guile-user

"Jon Wilson" <j85wilson@fastmail.fm> writes:

> Hi all,
> I just had a random idea, and thought I'd run it by y'all.  What if you
> could compose modules from the REPL, and then write them to a file? 

Or alternatively you could write some Emacs Scheme mode support to
allow you to evaluate definitions and expressions as you are writing
... which is what the "gds" stuff in my guile-debugging package does.

(Or at least aims to do; please let me know if you try it out and find
that it doesn't work for you.)

Regards,
    Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: idea: create module
  2006-04-25 23:05 ` Neil Jerram
@ 2006-04-26 13:51   ` Jon Wilson
  2006-04-27  7:42     ` Neil Jerram
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Wilson @ 2006-04-26 13:51 UTC (permalink / raw)


Hi Thien and Neil,
Those both sound like good solutions.  However, I was thinking of something 
within the language itself, rather than something outside, like emacs. 
This is partly because I don't use emacs, myself, and I am not particularly 
familiar with its capabilities versus vim.  Heck, I'm not sufficiently 
familiar with vim's capabilities, either, regardless that I use it every day.

I still think that something within the language would be useful, but 
perhaps I'm the only one, and thus should write it myself. :-p  Thanks for 
the good ideas, though!
Regards,
Jon

Neil Jerram wrote:
> "Jon Wilson" <j85wilson@fastmail.fm> writes:
> 
> 
>>Hi all,
>>I just had a random idea, and thought I'd run it by y'all.  What if you
>>could compose modules from the REPL, and then write them to a file? 
> 
> 
> Or alternatively you could write some Emacs Scheme mode support to
> allow you to evaluate definitions and expressions as you are writing
> ... which is what the "gds" stuff in my guile-debugging package does.
> 
> (Or at least aims to do; please let me know if you try it out and find
> that it doesn't work for you.)
> 
> Regards,
>     Neil
> 


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: idea: create module
  2006-04-26 13:51   ` Jon Wilson
@ 2006-04-27  7:42     ` Neil Jerram
  2006-05-02  4:08       ` Jon Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: Neil Jerram @ 2006-04-27  7:42 UTC (permalink / raw)
  Cc: guile-user

Jon Wilson <j85wilson@fastmail.fm> writes:

> Hi Thien and Neil,
> Those both sound like good solutions.  However, I was thinking of
> something within the language itself, rather than something outside,
> like emacs. This is partly because I don't use emacs, myself, and I am
> not particularly familiar with its capabilities versus vim.  Heck, I'm
> not sufficiently familiar with vim's capabilities, either, regardless
> that I use it every day.
>
> I still think that something within the language would be useful, but
> perhaps I'm the only one, and thus should write it myself. :-p  Thanks
> for the good ideas, though!
> Regards,
> Jon

Jon,

You may well be right.  Although my initial thought was to see it as
more natural to run guile within an editor (or some kind of IDE, more
generally), having the other way round available as well could be very
useful.  For example when one only has a terminal to work with.

I think a key question is what would you want to write out?  Would it
be a verbatim transcript of what was typed in, or would it be somehow
"improved" - e.g. by eliminating previous definitions of the same name
and/or trivial non-definitions?  Possibly even pretty-printed?

Regards,
        Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: idea: create module
  2006-04-27  7:42     ` Neil Jerram
@ 2006-05-02  4:08       ` Jon Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Jon Wilson @ 2006-05-02  4:08 UTC (permalink / raw)
  Cc: guile-user

Hi Neil,

Neil Jerram wrote:

>>I still think that something within the language would be useful, 
> 
> Jon,
> 
> You may well be right.  Although my initial thought was to see it as
> more natural to run guile within an editor (or some kind of IDE, more
> generally), having the other way round available as well could be very
> useful.  For example when one only has a terminal to work with.

Actually, until recently, the thought to run it in an editor had not 
occured to me.  I've been running vi in one screen and guile in another...

> 
> I think a key question is what would you want to write out?  Would it
> be a verbatim transcript of what was typed in, or would it be somehow
> "improved" - e.g. by eliminating previous definitions of the same name
> and/or trivial non-definitions?  Possibly even pretty-printed?
> 

My preference list:
1. Pretty-printed version of what was typed in.
2. Verbatim typed in.
3. pretty-printed values which are currently in all symbols marked for export.
4. values of export symbols.

I suspect that verbatim transcript would be rather wasteful of the REPL's 
memory, but if there's a good way to do it that I don't immediately see, 
then I think that would be best.  Otherwise we might wind up with modules 
which were utterly unmaintainable because module writers just got lazy and 
stuck with the memoized version of functions and such.

3 and 4 would be sufficient I think for quick and dirty work.  1 might be 
good enough for release code.

Hmm. As I finish writing this, I think "but aren't we already storing 
everything typed, provided readline is activated?"  So maybe 1 and 2 aren't 
that memory intensive after all.  Is there an easy way to access the 
readline history from guile?

Regards,
Jon


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-02  4:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-25  1:31 idea: create module Jon Wilson
2006-04-25  7:09 ` Thien-Thi Nguyen
2006-04-25 23:05 ` Neil Jerram
2006-04-26 13:51   ` Jon Wilson
2006-04-27  7:42     ` Neil Jerram
2006-05-02  4:08       ` Jon Wilson

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 read-only IMAP folder(s) and NNTP newsgroup(s).