On 09/01/2013, at 1:07 PM, srean wrote: > > Is writing C++ code indirectly via " " limited strings and $[:digits:] the > preferred way to do things ? That was what I was calling "opening the C++ > trapdoor". My plan was to avoid it as much as possible and write in Felix > syntax, well, thats Felix syntax as well, but I do not know how to explain > it. I also intended to avoid classes for the timebeing.
http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std/cmdopt.flx Is a fairly interesting "pure" Felix library module: its gets command line arguments in an "interesting" way. Not documented very well. Unfortunately this illustrates a problem learning Felix. This modules uses lib/std/list.flx (functional lists) lib/std/re2.flx (Google RE2 regexps) lib/std/strdict.flx (Dictionary with string keys) lib/std/string.flx (Strings) [and probably more stuff as well] I happen to know that, but unlike C/C++ there is no "include" of these files to hint that. Actually there is: lib/std/__init__.flx includes the whole standard library and is loaded automagically. The reason for doing this is to make standard features available without needing to "include" everything, and most often-used library classes are "open" by default so you don't need to use explicit::qualification to refer to a name. This makes the code cleaner and shorter and easier to read and write once you know what's in the library approximately, then you can browse the library using "grep" or the webserver or your editor. but it adds a huge entry barrier to newbies because they not only have to learn Felix the language but also a huge standard library as well. Even telling apart what's language and what's library is hard, especially in Felix because .. well because technically there isn't any difference :) At least part of your problem is that almost all the types and functions and things that do stuff in Felix ARE lifted out of C++. RE2 is C++. strdict is C. string is C++. Only list is pure Felix and even that has a bit of C in it :) Even when you're adding two integers in Felix: var x = 1 + 2; that's C++. Felix int is C++ int: http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std//ctypedefs.flx These are categorised into sets here there's so many of the dang things: http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std//ctypesets.flx The abstract properties of numbers are defined here: http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std//algebraic.flx as a mathematician you will understand this code, despite the fact it is using type classes. It's just defining groups and rings. The "Float" variant is there because floating point math isn't associative. Its the best I could think of to mean "approximately" since there's no universal way to say that for floats. And some of these abstractions are made concrete here: http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std//number.flx which is, naturally, done with bindings to C++. How else could it be done? Felix doesn't have any primitive types. It has type *constructors* such as tuple formation, sum types, pointer formation .. but no primitives. Indeed bool is defined by typedef bool = 2; and the common operations on it are given as C++ bindings: http://felix-lang.org/$/usr/local/lib/felix/felix-latest/lib/std//bool.flx which begs the question why this works, since 2 is a canonical sum type not an integer and not C++ bool. [The answer is that I rigged the compiler to make sure this works :] The bottom line here is that often its just *easier* to lift a type, function or procedure out of C++ to get the job done, than troll through the library. When in doubt, suffer lag and ask on this list. Its really the best way at the start. You need some understanding of Felix before you can read the library code (and even then, I myself have a lot of trouble finding the three places that define most stuff: the abstraction, the type definition, and the instance bindings of the type). I might refactor the library a bit to ease this burden but fundamentally systems are tied together in a spider web, hierarchies just don't work, and that's the best filesystems can do. Even HTML style hyperlinking, which is better, isn't enough. There's no easy answer. Learn one way to do things and stick to it so you can progress. So you can apply a function like this: f (x) and like this: f x and like this f $ x and like this x.f which is hard enough to learn to read let alone write. The first form is enough for everything. The rest is just to save on parentheses because we want to write nice code not Lisp :) So just use the first form you're familiar with so you can progress to learning at least one way to do other things. Post code and I'll help simplify it and that's a good way to learn the shortcuts. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language