R6RSは実用的な仕様がたくさん入っていて良いのですが getenv がなくて CGI プログラムが書けません。と文句を言うだけではもったいないのでSRFI(Scheme Requests for Implementation)に仕様を提案しようと決意。

shiroさんにアドバイス頂き

既存の実装を調査（Scheme/getenv/調査）

セマンティクスは Java を参考に

書いてみました。

いやあ難しい。ダメ出しつっこみをよろしくお願いします。

title Gets the value of the specified environment variable.

author Taro Minowa（Higepon）

Abstract This SRFI specifies the procedure getenv, gets the value of the specified environment variable.

Rationale Many Scheme implementations provide means for getting the value of the specified environment variable, usually called getenv.

Environment variables are conceptually mappings between names and values.

This mechanism can be used to pass system-dependent external information to a Scheme program.

Environment variables are widely used in many UNIX systems to specify optional parameters or environment dependent features.

In addition, some web application frameworks like CGI heavily use environment variables as the parameter from frontend web servers.

For example, CGI program uses following environment variables. ( getenv "QUERY_STRING" ) => "foo=bar&huga=hige" ( getenv "CONTENT_LENGTH" ) => "512" ( getenv "REQUEST_METHOD" ) => "post" Therefore, it is quite useful to define the environment-independent way to get environment variables.

Specification Function: getenv name Returns the value of the environment variable name as a string, or #f if the environment variable is not found. ( getenv "PATH" ) => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" Function: getenv Returns the list of all the environment variables as an a-list. ( getenv ) => (( "PATH" . "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ) ( "USERNAME" . "taro" ))

Implementation getenv procedure may be implemented with operating system dependent functions and variables.

On Unix getenv and environ, on Windows getenv_s and _environ may be used.

Copyright Copyright (C) Taro Minowa(Higepon) (2008). All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.