Created
March 13, 2015 01:41
-
-
Save astrieanna/9fc13e7721cbfab92f72 to your computer and use it in GitHub Desktop.
Using the output of code_typed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat_minor": 0, "cells": [{"execution_count": 2, "cell_type": "code", "source": "code_typed(+,(Int,)) # Array of Exprs, one per matching method.", "outputs": [{"execution_count": 2, "output_type": "execute_result", "data": {"text/plain": "1-element Array{Any,1}:\n :($(Expr(:lambda, {:x}, {{},{{:x,Int64,0}},{}}, :(begin # operators.jl, line 71:\n return x::Int64\n end::Int64))))"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 4, "cell_type": "code", "source": "e = code_typed(+,(Int,))[1] # Grab the first (and only) element", "outputs": [{"execution_count": 4, "output_type": "execute_result", "data": {"text/plain": ":($(Expr(:lambda, {:x}, {{},{{:x,Int64,0}},{}}, :(begin # operators.jl, line 71:\n return x::Int64\n end::Int64))))"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 5, "cell_type": "code", "source": "names(e) # Let's see what properties our Expr has", "outputs": [{"execution_count": 5, "output_type": "execute_result", "data": {"text/plain": "3-element Array{Symbol,1}:\n :head\n :args\n :typ "}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 6, "cell_type": "code", "source": "e.head", "outputs": [{"execution_count": 6, "output_type": "execute_result", "data": {"text/plain": ":lambda"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 7, "cell_type": "code", "source": "e.args", "outputs": [{"execution_count": 7, "output_type": "execute_result", "data": {"text/plain": "3-element Array{Any,1}:\n {:x} \n {{},{{:x,Int64,0}},{}} \n :(begin # operators.jl, line 71:\n return x::Int64\n end::Int64)"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "e.typ", "outputs": [{"execution_count": 8, "output_type": "execute_result", "data": {"text/plain": "Any"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Julia 0.3.6", "name": "julia 0.3", "language": "julia"}, "language_info": {"version": "0.3.6", "name": "julia"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment