Imagine a guy who builds cars. When he building a new car he’s always doing the same thing, more or less. So he builds factory to build cars, and it’s much better.
Now he wants to build new types of cars. Easiest way to do this is, creating new factory for each new type of cars. Now he decides to build factories that build factories that build cars. That’s metaprogramming.
In programming perspective,
Lets assume you wants to write shell script that will echo number one.
#!/bin/sh # program echo "1"
Then you wants a shell script that will echo number 2, and another shell script for echo number 3 and so on until 1000. You can write each shell script by manually or you can write shell script which will write a all those 1000 programs as following script (which is a meta program).
#!/bin/sh # metaprogram echo '#!/bin/sh' >program for I in $(seq…
View original post 11 mots de plus