Azamat_code-checkpoint



In [2]:
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ScopeCreator"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "module ScopeCreator\n",
    "\n",
    "export initialize\n",
    "\n",
    "function initialize(vars::Dict{Symbol, Any})\n",
    "    for (key, val) in vars\n",
    "        eval(:($key = $val))\n",
    "        # sanity check\n",
    "        println(key, \" = \", val)\n",
    "    end\n",
    "end\n",
    "\n",
    "end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "using ScopeCreator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Dict{Symbol,Any} with 2 entries:\n",
       "  :y => Bool[false,false,false]\n",
       "  :x => 1"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_vars = Dict(:x=>1, :y=>falses(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y = Bool[false,false,false]\n",
      "x = 1\n"
     ]
    }
   ],
   "source": [
    "initialize(test_vars)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "LoadError",
     "evalue": "LoadError: UndefVarError: x not defined\nwhile loading In[5], in expression starting on line 1",
     "output_type": "error",
     "traceback": [
      "LoadError: UndefVarError: x not defined\nwhile loading In[5], in expression starting on line 1",
      ""
     ]
    }
   ],
   "source": [
    "x   # should throw UndefVarError"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "LoadError",
     "evalue": "LoadError: UndefVarError: y not defined\nwhile loading In[6], in expression starting on line 1",
     "output_type": "error",
     "traceback": [
      "LoadError: UndefVarError: y not defined\nwhile loading In[6], in expression starting on line 1",
      ""
     ]
    }
   ],
   "source": [
    "y   # should throw UndefVarError"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 0.4.3",
   "language": "julia",
   "name": "julia-0.4"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "0.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-9d1aad779d0e> in <module>()
      5    "execution_count": 1,
      6    "metadata": {
----> 7     "collapsed": false
      8    },
      9    "outputs": [

NameError: name 'false' is not defined

In [ ]:


In [ ]: