If you could create your own language...

Pages: 1... 345
I mentioned a few months ago a kind of macro language that automated some tedious plain text formatting tasks:
http://www.cplusplus.com/forum/lounge/16821/#msg84877
@Kyon
In addition to chrisname's response, it will not work on Windows. For that you need different shell magic. :-]

foo
#! /usr/bin/env alsh 
print "Hello world!\n"


foo.bat
@alsh foo $*

Eh? Eh?

:-D
Aaargh, BATCH. :P Was hoping for a slightly more "common" way to do it, that would work for all OS's, but (*sigh*, Microsoft) Windows is being an ass as usual.
It's not that bad. MS is simply a different OS than *nix flavors. Same is true for Mac OSes prior to X.
True, but it's just that Batch's syntax sucks. AND Microsoft has exceptional things for practically anything. Hence, law 6: "Microsoft is always to blame."
Well, that's why there's PowerShell. Or you can use Bash, if you prefer.
Or, in modern versions of windows, just use a vbscript or javascript script file. If you want, you can even hook your own scripting language into the explorer shell.
I would very much like to know how to do that.
@helios,
What do you mean? I don't see how that would work.

To get the value of
	  4
	  Σ  2n
	n = 0

You would write,
1
2
Summation sum(0, 4, "2n");
result = sum.GetEvaluation();
Is this supposed to be in C++ or a different language?
I'm writing it in C++. A Summation is a class. This is most of it:
1
2
3
4
5
6
7
8
9
10
11
class Summation {
    private:
        long int start;
        long int limit;
        std::string expr;
        symbol sym;        
    public:
        Summation();
        Summation(long int startval, long int endval, const std::string& expression);
        long int GetEvaluation();
};
If you could create your own esoteric language...

I can think of atleast one interesting concept to apply:
- Just too-late compilation
Program is compiled and run upon execution, the actual executable is only temporary.
Just too-late compilation
Nice, although I feel the name doesn't quite match the concept. How about this? Each function is included twice in a compiled module; once as bytecode of the last version of the function, and again as source code of the current version. The outdated version in run, and once it returns, the newer one is compiled and stored. The old version is kept until the function is updated again.
The name was more to parody the "just in-time compilation", used by some languages. That seems nice (though, I don't think it's going to be implemented on anything anytime soon :P).
The Tcl bytecode compiler does just that.

Since "everything is a string" in Tcl, including the program itself, which can be modified along with any other data, the bytecode compiler will update "just-in-time" if you change a function/object/whatever.

:-]
Might be looking into that at a later date, if I ever get the time to do so, in the first place.
Topic archived. No new replies allowed.
Pages: 1... 345