dylan-hackers / mindy

Mindy - minimal compiler-interpreter for Dylan
Other
21 stars 9 forks source link

Single file program and Dylan script. #26

Open dram opened 9 years ago

dram commented 9 years ago

Note that even the minimal Dylan program has at least two files.

This statement in Mindy document seems to be not true.

hello-world example can be simplified to use only one file, as:

Module: dylan-user

define method main (name :: <byte-string>, #rest ignore)
  puts("Hello, World.\n");
end;

This file can run by following command:

mindycomp -o - hello.dylan  | mindy -x -

Combine with mindyexec, writing Dylan script using Mindy is possible:

#!/usr/bin/env mindyexec
Module: dylan-user

define method main (name :: <byte-string>, #rest ignore)
  puts("Hello, World.\n");
end;
waywardmonkeys commented 9 years ago

Hello!

This is true in this case, however, not in the more general case of when you need to use something that isn't part of the dylan library or perhaps having to import additional modules.

I think it would be great to:

The good news is that things are significantly easier to deal with here than they are in Open Dylan.

dram commented 9 years ago

For more general cases, I wrote a quick and dirty script yesterday:

https://gist.github.com/dram/a91e2911b6a0ec3d9238

It uses the page break character \f to seperate multple files, quite ugly, but it do works.

Waiting for more elegant solutions. :)

dram commented 9 years ago

Just figure out that Mindy support using library and module before being defined, as described in http://project-mindy.github.io/mindy/mindy.html#using-libraries-and-modules.

Then a single file Dylan script using library is possible, like this one:

#!/usr/bin/env mindyexec
library: hello-world
module: hello-world

define library hello-world
  use dylan;
  use format-out;
end;

define module hello-world
  use dylan;
  use extensions;
  use format-out;
end;

define method main (name, #rest ignore)
  format-out("Hello, world.\n");
end;
waywardmonkeys commented 9 years ago

This should work a lot better now, right? (although docs and other things need to be improved)

dram commented 9 years ago

Yes, nice work!

Now I'm waiting for system library to be migrated, some modules in it is essential for scripting. Also a nice interface to run external program is needed, system, piped-exec even Open Dylan's run-application is not power enough.

waywardmonkeys commented 9 years ago

What improvements would you like to see in run-application?

dram commented 9 years ago

Some random thoughts relate to run-application:

  1. supply arguments as a list instead of a plain string
  2. access stdin, stdout (something like piped-exec)

P.S. I think Python's subprocess module is well designed, also see Dart's Process class, and ASDF's run-program.