Perl HTML Shell
Switch branches/tags
Nothing to show
Clone or download
hzhou parse_code() no longer used
	modified:   compileutil.def
	modified:   mydef_debug.def
Latest commit 9d8b44d Jul 13, 2018
Failed to load latest commit information.
bootstrap loop { break flag_xxx } $if flag_xxx ... May 31, 2018
deflib modified: deflib/perl/gnuplot.def May 3, 2018
docs fncode: F(paramline): return_type Apr 26, 2018
macros_compile $(M:regex:(capture)) Jul 12, 2018
macros_make modified: compile/macro.def Jan 9, 2017
macros_output fix indentation error Jul 13, 2018
macros_parse modified: macros_compile/parse.def Jun 24, 2018
macros_util modified: docs/mydef.vim Mar 15, 2018
manual modified: mydef.html Mar 29, 2018
old $(stub: && :subname) May 8, 2018
tests $plugin now support normal call_sub and eval persub Jul 9, 2018 new file: Jul 12, 2018 modified: Jul 10, 2018 modified: Jan 30, 2018
compileutil.def parse_code() no longer used Jul 13, 2018
config new file: config Dec 9, 2013
dumpout.def INCLUDE_FILE Jun 26, 2018 modified: Mar 25, 2017
modules.def output_f90 Jul 13, 2018
mydef.def modified: mydef.def Feb 25, 2018
mydef_debug.def parse_code() no longer used Jul 13, 2018
mydef_decl.def retab Apr 23, 2015
mydef_ext.def modified: mydef_ext.def Jan 7, 2018
mydef_install.def modified: bootstrap/script/mydef_install Mar 27, 2018
mydef_make.def modified: compileutil.def May 10, 2018
mydef_page.def modified: mydef.def Feb 25, 2018
mydef_run.def output_f90 Jul 13, 2018
mydef_update.def modified: lib/ Nov 15, 2017
mydef_utils.def new subcode merging algorithm, now merges at the end May 11, 2018
output.def output_f90 Jul 13, 2018
output_general.def Simplified the NEWBLOCK mechanism, hopefully more robust (verified in… May 24, 2016
output_perl.def modified: dumpout.def Jun 24, 2018
parseutil.def modified: dumpout.def Jun 24, 2018

An old tutorial is available at

A more thorough manual that will be kept within the repository is currently in progress. You can view it here.

MyDef is not a new programming language. It is an additional layer on top of your programming language -- a layer that can do almost anything without affecting the demands of the underlying language. The layer can be very thin, in which case you still write your code exactly the same way you used to. And you should if you never had complaints in your programming career. But if you do, MyDef allows you to do something about it.

  • I have always complained about semicolons. Now with MyDef, I don't type them anymore.
  • I have complained about curly braces. Now with MyDef, I avoided them, along with the grammatical parentheses.
  • I have wished to refactor my code without worry about variable scopes. MyDef allows me to refactor with no side effects.
  • I have wished a less uglier way to write JavaScript, with MyDef, I like the new look.
  • etc.

And they are not on/off switches. You may start refactoring part of your code, and simply paste the rest of your legacy code. Unlike other programming language which will tell you what to do -- often strictly, you just do what you want to do in MyDef. You do need know what you want to do though.

I cannot show you the freedom unless you feel the restriction. Before you ask what good does MyDef buy you, recall what bad you have complained. MyDef offers solutions -- without changing your language and still allowing collaboration with your fellow coworkers even when they are stuck in their primal language.

MyDef is not just syntax, it is about paradigm. If you have a vision on how you think to program, MyDef can realize them. Contrary to what others may preach, you don't need classes to do object oriented programming, you don't need first-class functions to do functional programming. You program in objects when you are thinking in objects, and you program functionally when you are thinking in pure functions. Do you want a language restrict you on how to think? MyDef liberates you.


  1. Dependency:

     perl -- base language
     make, sh, git -- convenience requirement, only tested with GNU make, bash
     vim -- optional, but you need an editor that supports indentation, syntax, and short-cut keys
  2. MyDef currently is in perl. First setup a custom installation environment:


    The purpose is to install into one's home directory rather than system folders. I assume you will know how to change it into any installation destination.

  3. Now install it:

  4. If you haven't, read the documentation:

  5. Try it. e.g.

     $ vim t.def
     page: t
         module: perl
         $print Hello World!
     $ mydef_run t.def

    Explanation: page outputs a file in that name with the default extension -- in this case $print is special since it is used so often. It is customized in MyDef to provide many convenience (and a uniform syntax across languages) In this case, it is translated into print("Hello World!\n"); mydef_run is a convenience for short script. Formally, mydef_page compiles .def into .pl (or whatever language of the module), and the normal toolchain of the language follows. mydef_page is what should be used in a Makefile.

  6. If you use vim, there is simple mydef syntax.

     $ vim ~/.vim/filetype.vim
     augroup filetypedetect
     au BufNewFile,BufRead *.def setf mydef
     augroup END
     $ ln -s /path/to/MyDef/docs/mydef.vim ~/.vim/syntax/

    lastly, in .vimrc, I would consider minimally:

     :set shiftwidth=4
     :set expandtab 
     :nmap <F5> :!mydef_run %<CR>
  7. Set those environment variables in step 1 in your login shell's startup file. In addition, set:

     MYDEFSRC=[your MyDef path]
     export MYDEFSRC

This is needed when you install or develop specific output modules.

More Output Modules

This repository only contains the general and perl output modules. You can use the general output module for any text based code. However, there are specialized output modules for various programming languages. For example, if you are working with C/C++ code, you may want to try the output_c module: