# Internal Definitions

In section 3.2.3 we saw how the environment model described the behavior of procedures with local state. Now we have seen how internal definitions work. A typical message-passing procedure contains both of these aspects. Consider the bank account procedure of section 3.1.1 :

``````(define (make-account balance)
(define (withdraw amount)
(if (>= balance amount)
(begin (set! balance (- balance amount))
balance)
"Insufficient funds"))
(define (deposit amount)
(set! balance (+ balance amount))
balance)
(define (dispatch m)
(cond ((eq? m 'withdraw) withdraw)
((eq? m 'deposit) deposit)
(else (error "Unknown request -- MAKE-ACCOUNT"
m))))
dispatch)``````

Show the environment structure generated by the sequence of interactions

``````(define acc (make-account 50))

((acc 'deposit) 40)
90

((acc 'withdraw) 60)
30``````

Where is the local state for `acc` kept? Suppose we define another account

``(define acc2 (make-account 100))``

How are the local states for the two accounts kept distinct? Which parts of the environment structure are shared between `acc` and `acc2` ?
{"ft_lang_label":"__label__en","ft_lang_prob":0.8140746,"math_prob":0.9675963,"size":1148,"snap":"2022-40-2023-06","text_gpt3_token_len":261,"char_repetition_ratio":0.13548951,"word_repetition_ratio":0.0,"special_character_ratio":0.25,"punctuation_ratio":0.088541664,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97736585,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-08T14:52:08Z\",\"WARC-Record-ID\":\"<urn:uuid:dad6a766-b1a0-4cfc-b1b3-e8aa4f78094d>\",\"Content-Length\":\"14050\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:556dbfc8-d33c-43a8-8a68-bc6cde272241>\",\"WARC-Concurrent-To\":\"<urn:uuid:967b92e1-6b79-444a-96fb-19da50a96af4>\",\"WARC-IP-Address\":\"63.32.161.232\",\"WARC-Target-URI\":\"https://sicp.hexlet.io/exercises/154\",\"WARC-Payload-Digest\":\"sha1:72PXN7S2AKAPAVIWE3MIEXYX7HMJ3QQC\",\"WARC-Block-Digest\":\"sha1:W3DTTCVTC5DJGLV7PZJOCAXHQRXS75A4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500813.58_warc_CC-MAIN-20230208123621-20230208153621-00598.warc.gz\"}"}