Original articles by Mark Leair, PGI Compiler Engineer
This is Part 1 of a series of articles:
Original articles by Mark Leair, PGI Compiler Engineer
This is Part 1 of a series of articles:
${ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
char *var(int fresh); | |
char *append(char *format, char *buf, char *str); | |
#define ABST(BUF, STR) append("%s%s: ", (BUF), (STR)) | |
#define APPL(BUF, STR) append("%s%s ", (BUF), (STR)) |
#include <assert.h> | |
#include <ctype.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
static void bout(char *msg) __attribute__((noreturn)); | |
static int calc_expr(void); | |
static int calc_term(void); | |
static int calc_factor(void); |
#include <assert.h> | |
#include <ctype.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
static void bout(char *msg) __attribute__((noreturn)); | |
static int calc_expr(int val, int op); | |
static int calc_term(int val, int op); | |
static int calc_factor(void); |
This post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
#!/usr/bin/env bash | |
# Only ksh93 has "real" C++-like references (called namerefs). They can be used | |
# as reference parameters for passing data structures like arrays in and out of | |
# functions. Bash 4.3+ and mksh also have a nameref feature, but unlike ksh93, | |
# which has three different kinds of nameref, bash supports just two of these | |
# and mksh only one (the for-loop type won't be illustrated here). It is the | |
# "dynamic" kind of nameref that is supported by all three, which is mostly | |
# just sugar for Bash's old "${!var}" behavior (ksh93 also uses this kind when | |
# a nameref doesn't refer to a positional parameter). |
(load "graph_util") | |
(defparameter *congestion-city-nodes* nil) | |
(defparameter *congestion-city-edges* nil) | |
(defparameter *visited-nodes* nil) | |
(defparameter *node-num* 30) | |
(defparameter *edge-num* 45) | |
(defparameter *worm-num* 3) | |
(defparameter *cop-odds* 15) |
# Roman Numeral Evaluation is a Monoid | |
# Chad Brewbaker | Software Engineer | Telligen.org | |
# [email protected] | |
# Initial release January 15, 2013 | |
class RomanMonoid | |
attr_accessor :prefix, :prefix_size, :suffix, :suffix_size, :suffix_credit, :sum, :homo | |
def initialize(val) |
program a | |
use types, only: dp | |
use compute, only: init, register_func, run, eq, destroy, get_context | |
use my_data_type, only: my_data, type2data, data2type | |
type(eq), pointer :: d | |
type(my_data), target :: data1, data2 | |
data1%a11 = 0 | |
data1%a12 = -1 |