Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

05-09-2010 /prog/ Challenge

Name: Anonymous 2010-09-06 0:06

Write a procedure find-variable that takes as arguments a variable and a compile-time environment and returns the lexical address of the variable with mad respect to that environment.

Name: Anonymous 2010-09-06 0:20

You're going to have to specify how you pass a "compile-time environment" to a function.  Also might help to say what language.

Name: Anonymous 2010-09-06 0:22

>>2
I think only Forth and Lisp accept dashes in identifiers.

Name: Anonymous 2010-09-06 0:41

with mad respect to that environment
WHAT

Name: Anonymous 2010-09-06 0:46

>>3
And COBOL.

Name: Anonymous 2010-09-06 1:06

The problem with this challenge is that the environment's structure is different for each implementation, on CLISP it's a dumb (recurive) vector(for easier acess from C), on SBCL it's a fancy structure, on CCL it's a structure as well (however, structures there are most certainly always implemented with vectors), and so on. Since I don't know the exact meaning of "lexical address of the variable with mad respect to that environment", I'll just show how I located a variable in 3 minutes within the environment object without much prior knowledge of the compiler internals, and instead just using my instincts and general lisp knowledge to inspect compiler(SBCL) internals:

CL-USER> (defmacro get-environment (&environment env) env)
GET-ENVIRONMENT
CL-USER> (get-environment)
#<NULL-LEXENV>
CL-USER> (let ((x 1)) (get-environment))
; in: LAMBDA NIL
;     (LET ((X 1))
;       (GET-ENVIRONMENT))
;
; caught STYLE-WARNING:
;   The variable X is defined but never used.
;
; compilation unit finished
;   caught 1 STYLE-WARNING condition
#S(SB-KERNEL:LEXENV
   :FUNS NIL
   :VARS ((X . #<SB-C::LAMBDA-VAR :%SOURCE-NAME X {24626819}>))
   :BLOCKS NIL
   :TAGS NIL
   :TYPE-RESTRICTIONS NIL
   :LAMBDA #<SB-C::CLAMBDA
             :%SOURCE-NAME SB-C::.ANONYMOUS.
             :%DEBUG-NAME (LET ((X 1))
                            )
             :KIND :ZOMBIE
             :TYPE #<SB-KERNEL:BUILT-IN-CLASSOID FUNCTION (read-only)>
             :WHERE-FROM :DEFINED
             :VARS (X) {24626949}>
   :CLEANUP NIL
   :HANDLED-CONDITIONS ((COMPILER-NOTE . MUFFLE-WARNING))
   :DISABLED-PACKAGE-LOCKS NIL
   :%POLICY ((COMPILATION-SPEED . 1) (DEBUG . 1) (INHIBIT-WARNINGS . 1)
             (SAFETY . 1) (SPACE . 1) (SPEED . 1))
   :USER-DATA NIL)
CL-USER> (sb-c::lexenv-vars *)
((X . #<SB-C::LAMBDA-VAR :%SOURCE-NAME X {24626819}>))
CL-USER> (assoc 'x *)
(X . #<SB-C::LAMBDA-VAR :%SOURCE-NAME X {24626819}>)
CL-USER> (cdr *)
#<SB-C::LAMBDA-VAR :%SOURCE-NAME X {24626819}>
CL-USER> (describe *)
#<SB-C::LAMBDA-VAR :%SOURCE-NAME X {24626819}>
  [structure-object]

Slots with :INSTANCE allocation:
  NUMBER             = 4
  NUMBER             = 4
  %SOURCE-NAME       = X
  TYPE               = #<SB-KERNEL:NAMED-TYPE T>
  DEFINED-TYPE       = #<SB-KERNEL:NAMED-TYPE T>
  WHERE-FROM         = :ASSUMED
  REFS               = NIL
  EVER-USED          = T
  DYNAMIC-EXTENT     = NIL
  INFO               = NIL
  SETS               = NIL
  FLAGS              = 0
  HOME               = #<SB-C::CLAMBDA..
  ARG-INFO           = NIL
  SPECVAR            = NIL
  CONSTRAINTS        = NIL
  LAST-INITIAL-TYPE  = #<SB-KERNEL:NAMED-TYPE T>
  FOP-VALUE          = NIL
; No value
CL-USER>

Name: Anonymous 2010-09-06 12:53

caught STYLE-WARNING:
oh my

Name: Anonymous 2010-09-06 17:16

>>6
This is a really tedious way of saying >>2

Name: Anonymous 2010-09-06 17:26


ML [[options]] filename [[ [[options]]  filename]]

Option               Action
/Fm[[filename]]         Creates a linker map file.

Name: Anonymous 2010-09-07 2:09

>>1
It's not May anymore!

Name: Anonymous 2010-09-07 9:50

>>10
Fuck off, ``yankee''

Name: Anonymous 2010-12-09 8:33

Name: Anonymous 2010-12-23 6:44

Name: Anonymous 2011-02-02 22:45

<

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List