#!/usr/bin/env python | |
# encoding: utf-8 | |
# Copyright (C) 2001-2007 Martin Blais. All Rights Reserved | |
# Copyright (C) 2010 Bear http://code-bear.com/bearlog/ | |
# Copyright (C) 2013 lrq3000 | |
# Excerpt from SnakeFood to recursively list all imports of modules using AST parsing | |
# Additions to print the versions of each module if available |
class LoopLabel(object): | |
def __init__(self): | |
super(LoopLabel, self).__init__() | |
class MyLoopLabel(Exception): pass | |
self._label_exception = MyLoopLabel | |
def __enter__(self): | |
return self._label_exception |
-- copy.lua | |
-- | |
-- Lua functions of varying complexity to deep copy tables. | |
-- | |
-- 1. The Problem. | |
-- | |
-- Here's an example to see why deep copies are useful. Let's | |
-- say function f receives a table parameter t, and it wants to |
""" | |
Inserts C code directly into Python files, which can then be dynamically linked | |
in and called via ctypes. | |
""" | |
import atexit | |
import ctypes | |
import os | |
import shlex | |
import sys | |
import tempfile |
*.pyc |
I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.
There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.
As an example, currently we can express this type:
import json | |
import socket | |
from struct import Struct, calcsize | |
from select import select | |
__all__ = ("Server", "Client", "localhostname", "localhost", "LAN", "WAN") | |
_int = "H" # 0 <= number <= 65535 == 2 ** 16 -1 | |
_size = calcsize(_int) | |
_struct = Struct("!" + _int) |
This post was written primarily to organize my thoughts during the design process. I'll explain the thought process that led me to each point in the design space we visit, then point out any issues, which will lead into the next iteration. Along the way, I made a few errors, which I'll try to rectify in the (Side Notes).
Here we go!