A small mod now allows this: Shell::system("ls","-lasp"); Shell::system("ls"); Shell::system ("ls","-lasp","*.flx");
What's the big deal? An apparent variable number of arguments! Really? Heck NO, Felix doesn't support that. No, what we have is: gen system[T with Streamable[T,string]] (args:T) : int = { var lst = Empty[string]; for arg in args do lst = lst + arg; done return system args; } So we're using an iterator method (implicit in the for loop) to access an arbitrary Streamable (any data structure with an iterator method). Lists are Steamable, and we're making one, but the return statement calls // list of string argument gen system (args:list[string]) : int => args.create_system_command.system ; because it is more specialised. That quotes the arguments and in turn calls: // string argument gen system (cmd:string) = { if Env::getenv "FLX_SHELL_ECHO" != "" do eprintln$ "[system] " + cmd; done return basic_system cmd; } Note "string" is a Streamable too: it's a stream of chars. So watch out! But this one is more specialised. And it calls //$ basic command with line quoting. gen basic_system (cmd: string) :int => cmd.quote_line_for_system.raw_system ; which in turn calls: //$ System command is ISO C and C++ standard. gen raw_system: string -> int = "::std::system($1.c_str())" requires Cxx_headers::cstdlib ; i will note in passing 'bash' is a piece of crap and the third call in the original text won't work because quoted wildcards aren't expanded. $ENV_IRON_MENT variables are expanded in double quotes. If we use \ quoting instead of quote marks, * wildcards are expanded which is no good if we're trying to pass a regex containing a *. The bottom line is that "transparent" shell calling is impossible by definition because we cannot distinguish between wildcards to be expanded and those which are not. HOWEVER the real point is yet to be made! How do we get the variable length arguments? The answer is: ("hello", "world") is a tuple of strings which is an array of length 2 which is a Streamable. As you know Felix doesn't have dynamic typing (as such), but this is very scripting language like.. something about quacking like ducks comes to mind .. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. This 200-page book is written by three acclaimed leaders in the field. The early access version is available now. Download your free book today! http://p.sf.net/sfu/neotech_d2d_may _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language