Skip to content

Instantly share code, notes, and snippets.

View cmoore's full-sized avatar
🆑

Clint Moore cmoore

🆑
View GitHub Profile

Reader Macros in Common Lisp

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.

Macros and read-macros see your program at different stages. Macros get hold of the program when it has already been parsed into Lisp objects by the reader, and read-macros operate on a program while it is still text. However, by invoking read on this text, a read-macro can, if it chooses, get parsed Lisp objects as well. Thus read-macros are at least as powerful as ordinary macros.

@HookHandler
public void onBlockRightClickHook(BlockRightClickHook hook) {
if (hook.getPlayer().getWorld().getFqName().equals("ctf_NORMAL")) {
hook.getBlockClicked().getPropertyKeys().forEach(new Consumer<BlockProperty>() {
@Override
public void accept(BlockProperty prop) {
hook.getPlayer().notice("P: ".concat(prop.getName()));
}});
}
}
private void show_tags(CompoundTag ctag, Player player) {
ctag.keySet().forEach(new Consumer<String>() {
@Override
public void accept(String s) {
player.notice("S: " + s + " V: " + ctag.get(s).toString());
}});
}
}
package me.swiftymove.Command;
import net.canarymod.Canary;
import net.canarymod.commandsys.CommandDependencyException;
import net.canarymod.plugin.Plugin;
public class Main extends Plugin{
@Override
public void disable() {
// The listener class for Beton...
package io.ivy.fawkes.beton;
import pl.betoncraft.betonquest.core.QuestEvent;
public class TestEvent extends QuestEvent {
public TestEvent(String playerID, String instructions) {
super(playerID, instructions);
System.out.println("TEST EVENT");
}
public class Utils {
public static List<Chest> find_all_chests(World world) {
List<Chest> chests = new ArrayList();
int tile_entities = 0;
for (Chunk c : world.getLoadedChunks()) {
for (BlockState b : c.getTileEntities()) {
tile_entities++;
[04:13:40 INFO]: hydo: Opped hydo
[04:13:48 INFO]: hydo issued server command: /gm c
[04:13:52 INFO]: hydo issued server command: /time set 1000
[04:14:00 INFO]: hydo issued server command: /weather clear
[04:14:41 INFO]: hydo issued server command: /npc create Bob The Builder
[04:14:56 INFO]: hydo issued server command: /trait builder
[04:17:43 INFO]: hydo issued server command: /builder load kataphane
[04:18:07 INFO]: hydo issued server command: /builder origin
[04:18:13 INFO]: hydo issued server command: /builder build
[04:18:13 ERROR]: null
(defvar *previous-readtables* nil)
(defmacro enable-toml-syntax ()
'(eval-when (:compile-toplevel :load-toplevel :execute)
(push *readtable* *previous-readtables*)
(setq *readtable* (copy-readtable))
(set-macro-character #\[ 'read-left-bracket)
; more calls to (set-macro-character)
...))
module Network.SunlightLabs.Legislators where
import Network.SunlightLabs.Utils
import Network.SunlightLabs.JSON
import Control.Monad
import Data.Maybe
import Network.HTTP
import qualified Data.Map as M
module Euler where
import List
import Control.Parallel
import Char
is_by_5 x = x `mod` 5 == 0
is_by_3 x = x `mod` 3 == 0