Giter VIP home page Giter VIP logo

m4's Introduction

m4

マクロプロセッサ

FizzBuzz

bin/fizzbuzz が対話環境の起動用シェルスクリプトです。
src/fizzbuzz.m4 を読み込ませ、警告/デバッグオプションを自動で設定してくれます。

$ ./bin/fizzbuzz
fizzbuzz(1, 15)
1, 2, 3 <- Fizz, 4, 5 <- Buzz, 6 <- Fizz, 7, 8, 9 <- Fizz, 10 <- Buzz, 11, 12 <- Fizz, 13, 14, 15 <- FizzBuzz

テスト

$ ./test.bash

m4's People

Contributors

0918nobita avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

m4's Issues

契約プログラミング (Contracts) をサポートする

What

マクロ展開の

  • 事前条件
  • 事後条件

を明記して、展開時に自動でアサーションが行われるようにするための各種ライブラリを追加する。

Why

  • マクロ定義中で、想定している引数の形式/展開後の状態を明記したい
  • アサーションの処理を毎回直接記述するとマクロ定義が煩雑になってしまう

空リストの表現方法を決める

問題点

include(list.m4)dnl
define([list_a], [])dnl
define([list_b], [foo])dnl
define([list_c], [foo, bar])dnl
length([list_a])
dnl => 1 (list_a を「空文字列1つを要素に持つリスト」として扱ってしまう)
length([list_b])
dnl => 1
length([list_c])
dnl => 2

というふうに、現状の length マクロでは空リストを適切に扱えない

解決策

空リストの特別な表現 ( empty 等) を用意する

実行時型識別 (RTTI) をサポートする

What

実行時型識別 (RTTI) を含む値のフォーマットを規定し、それを扱うためのライブラリを用意する

Why

マクロ展開中は文字列を様々な意味に再解釈できるが、それは「あるマクロから呼び出される別のマクロに文脈が正しく伝わっていない状態」を生み出す可能性がある

第一級関数オブジェクトを扱えるようにする

  • 環境(変数名と値の対応関係)
  • 定義コード

のふたつを管理する必要があり、定義コード内で環境内の変数を参照している場合は、どんな文脈で呼び出されても同じ環境の同じ変数を参照しなければならない。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.