Re: Packages
- Posted by Matt Lewis <matthewwalkerlewis at ?mail.c?m> Aug 08, 2007
- 555 views
Jason Gade wrote: > > Are you going to make a feature-testing branch for this? No way. Live fast, baby. I figure that since Rob stated before that this would probably go into the code, and since no one has spoken ill of it (except to say that it doesn't go far enough--and we can always extend it later), I'm putting it right into the trunk. ...and it's there right now. I managed to get it to work in the interpreter and the translator--although it occurs to me that I didn't update the Euphoria-based backend...so I'll have to go back and do that (it's just RTLookup, which is used by routine_id--the other resolution will work, because it's all front-end stuff). I also even updated the docs (though I suspect some may want to edit them). And here is the updated test suite for the new feature. I added frank.e to show that included files could still access global symbols in the files that included them (as long as the symbol was declared before the file was included, of course).
-- alice.e global sequence name name = "Alice" -- bob.e include alice.e global integer x x = 1 global procedure bob_name() printf(1,"Bob says name = \"%s\"\n",{name}) end procedure global procedure foo() puts(1, "bob.e foo()\n" ) end procedure -- chris.e global sequence name ? x -- ok, this is dumb, but shows that normal -- Eu resolution is still in effect name = "Chris" global procedure foo() puts(1,"chris.e foo()\n" ) end procedure -- diane.e include chris.e include frank.e global procedure diane_name() printf(1,"Diane says name = \"%s\"\n",{name}) end procedure -- erin.ex global procedure erin() puts(1, "erin\n") end procedure include bob.e as b include diane.e as d include alice.e as a include chris.e as c bob_name() diane_name() printf(1,"a:name = \"%s\" c:name = \"%s\" d:name = \"%s\"\n",{a:name,c:name, d:name}) printf(1, "d:x = %g\n", d:x ) printf(1, "erin routine_id(\"foo\") = %d\n", routine_id("foo") ) printf(1, "erin routine_id(\"b:foo\") = %d\n", routine_id("b:foo") ) printf(1, "erin routine_id(\"c:foo\") = %d\n", routine_id("c:foo") ) printf(1, "erin routine_id(\"d:foo\") = %d\n", routine_id("d:foo") ) puts(1, "\n\nAbove output should read:\n" & "1\n" & "erin\n" & "Bob says name = \"Alice\"\n" & "Diane says name = \"Chris\"\n" & "a:name = \"Alice\" c:name = \"Chris\" d:name = \"Chris\"\n" & "d:x = -1.23457\n" & "erin routine_id(\"foo\") = -1\n" & "erin routine_id(\"b:foo\") = 0\n" & "erin routine_id(\"c:foo\") = 1\n" & "erin routine_id(\"d:foo\") = 1\n" ) global atom x x = -1.23456789 erin()