
1: @node Concepts, Programming in Gauche, Introduction, Top 2: @chapter Concepts 3: @c NODE ???ʳ?ǰ 4: 5: @c EN 6: In this chapter I describe a few Gauche's design concepts 7: that help you to understand how Gauche works. 8: @c JP 9: ??ϤǤϡ?Gaucheư????ʤȤʤ뤤???Ĥ??γ?ǰ?????Þ¤??? 10: Gauche???????Τ??????ˤʤ??פ??Þ¤??? 11: @c COMMON 12: 13: @menu 14: * Standard conformance:: 15: * Multibyte Strings:: 16: * Multibyte scripts:: 17: * Case-sensitivity:: 18: * Integrated Object System:: 19: * Module system:: 20: * Compilation:: 21: @end menu 22: 23: @node Standard conformance, Multibyte Strings, Concepts, Concepts 24: @section Standard conformance 25: @c NODE ɸ???ν? 26: 27: @c EN 28: Gauche conforms "Revised^5 Report of Algorithmic Language Scheme," 29: including optional syntax and procedures, except the following features. 30: @c JP 31: Gauche?Ï¡??ʲ??˵󤲤?????????×¥???????ʸ??³??????Revised^5 Report of Algorithmic Language Scheme" ?˽????Ƥ??Þ¤??? 32: @c COMMON 33: 34: @itemize @bullet 35: @item 36: @c EN 37: By default, Gauche reads symbols in case-sensitive way. 38: A command-line option is provided to make the reader case-insensitive. 39: (@xref{Case-sensitivity}, for details). 40: @c JP 41: ?Ç¥Õ¥????Ç¡?Gauche?Ï¥????̾????????????Þ¤??? 42: ???Þ¥?饤?󥪥ץ????ˤ??Æ¡??ʸ????????ʤ??⡼?ɤ??????뤳?Ȥ??Ǥ??Þ¤?(@ref{Case-sensitivity}?????? 43: @c COMMON 44: @item 45: @c EN 46: Continuations created in a certain situation 47: (specifically, inside a Scheme code that is called from external 48: C routine) have limited extent (@xref{Continuation}, for details). 49: @c JP 50: ?????ï²¼?Ǻ??줿????ϸ¤??????????Æ¥???Þ¤? 51: (????ˤϡ?C?Î¥????ɤ??饳?????Ã¥??Ȥ??ƸƤФ?Scheme?????????????? 52: ??????????????)???ܤ?????ref{Continuation}?ò»²¾È¤??Ʋ??????? 53: @c COMMON 54: @item 55: @c EN 56: Full numeric tower (integer, rational, real and complex numbers) are supported, 57: but ratinals are only exact, and complex numbers are always inexact. 58: The reader can recognize '@code{#}' as insignificant digits. 59: @c JP 60: ?????umeric tower(??????ô¡¢¼Â¿????????Ý¡??Ȥ????????? 61: Í?????Τ?????Τߤǡ??Þ¤?Ê£??????Τ?????Τߤ??Þ¤??? 62: ?꡼??Ï¡????˱ƶ????ʤ???'@code{#}'????????????????Þ¤??? 63: @c COMMON 64: @item 65: @c EN 66: Procedures @code{rationalize}, @code{transcript-on} and @code{transcript-off} 67: are not supported. 68: @c JP 69: ????@code{rationalize}??@code{transcript-on}???Ú¤?code{transcript-off} 70: ?Ï¥??Ý¡??Ȥ??????Þ¤???@c COMMON 71: @end itemize 72: 73: @c EN 74: (Note: A new Scheme standard R6RS has been ratified on September 2007. 75: Although we don't have a plan to change Gauche to conform R6RS in near future, 76: we'll gradually add modules that are compatible to R6RS). 77: @c JP 78: (???2007ǯ9??????????cheme?????????RS?????????????? 79: Gauche??S???ˤ?????϶ᤤ????ˤϤ??????󤬡? 80: R6RS?ȸߴ??ʥ⥸?塼??????ä??Ƥ椯ͽ??Ǥ???) 81: @c COMMON 82: 83: @c EN 84: Gauche also supports the following SRFIs (Scheme Request for Implementation). 85: @c JP 86: Gauche?Ϥޤ????ʲ???RFI?ò¥µ¥Ý¡??Ȥ??Ƥ??Þ¤??? 87: @c COMMON 88: 89: @table @asis 90: @c EN 91: @item SRFI-0, Feature-based conditional expansion construct. 92: As an autoloaded macro. @xref{Feature conditional}. 93: @c JP 94: @item SRFI-0, ??ǽ?Ù¡????ξ???? 95: ?????È¥í¡¼?ɤ????Þ¥??????Æ¥??Ý¡??Ȥ???????@ref{Feature conditional}???È¡? 96: @c COMMON 97: 98: @c EN 99: @item SRFI-1, List library. 100: Supported by the module @code{srfi-1}. @xref{List library}. 101: (Some of SRFI-1 procedures are built-in). 102: @c JP 103: @item SRFI-1, ?ꥹ?ȥ饤?Ö¥? 104: ?⥸?塼??ode{srfi-1}?Ç¥??Ý¡??Ȥ???????@ref{List library}???È¡? 105: SRFI-1?μ????Τ???????Ĥ???Ȥ߹??ߤˤʤäƤ??Þ¤??? 106: @c COMMON 107: 108: @c EN 109: @item SRFI-2, AND-LET*: an AND with local bindings, a guarded LET* special form. 110: Supported natively. @xref{Binding constructs}. 111: @c JP 112: @item SRFI-2, AND-LET*: ?ɽ??????? AND?????????LET* ?????????Ȥ߹??ߤǤ???@ref{Binding constructs}???È¡? 113: @c COMMON 114: 115: @c EN 116: @item SRFI-4, Homogeneous numeric vector datatypes. 117: The module @code{gauche.uvector} provides a superset of 118: @code{srfi-4} procedures, including arithmetic operations and 119: generic interface on the SRFI-4 vectors. @xref{Uniform vectors}. 120: @c JP 121: @item SRFI-4, ???Ê¿?Ù¥????? 122: ?⥸?塼??ode{gauche.uvector}?? 123: @code{srfi-4}?ξ??ß´???????????Þ¤??? 124: Ʊ?⥸?塼????RFI-4?μ????˲ä??? 125: ???ѱ黻?䥸???Í¥????Ê¥??󥿥ե????????????????Þ¤???@ref{Uniform vectors}???È¡? 126: @c COMMON 127: 128: @c EN 129: @item SRFI-5, A compatible let form with signatures and rest arguments 130: Supported by the module @code{srfi-5}. 131: @xref{A compatible let form with signatures and rest arguments}. 132: @c JP 133: @item SRFI-5, ?????Í¥??rest???ß´???Τ???t??? 134: ?⥸?塼??ode{srfi-5}?Ç¥??Ý¡??Ȥ??????? 135: @ref{A compatible let form with signatures and rest arguments}???È¡? 136: @c COMMON 137: 138: @c EN 139: @item SRFI-6, Basic String Ports. 140: SRFI-6 procedures are built-in. @xref{String ports}. 141: @c JP 142: @item SRFI-6, ?????????SRFI-6?μ?????Ȥ߹??ߤˤʤäƤ??Þ¤???@ref{String ports}???È¡? 143: @c COMMON 144: 145: @c EN 146: @item SRFI-7, Feature-based program configuration language 147: Supported as an autoloaded macro. 148: @xref{Feature-based program configuration language}. 149: @c JP 150: @item SRFI-7, ??ǽ?Ù¡????×¥í¥°???????????È¥í¡¼?ɤ????Þ¥??????Æ¥??Ý¡??Ȥ??????Þ¤??? 151: @ref{Feature-based program configuration language}???È¡? 152: @c COMMON 153: 154: @c EN 155: @item SRFI-8, receive: Binding to multiple values. 156: Syntax @code{receive} is built-in. @xref{Binding constructs}. 157: @c JP 158: @item SRFI-8, receive: ¿?«? 159: ??ʸ@code{receive}??Ȥ߹??ߤˤʤäƤ??Þ¤???@ref{Binding constructs}???È¡? 160: @c COMMON 161: 162: @c EN 163: @item SRFI-9, Defining record types. 164: Supported by the module @code{srfi-9}. @xref{Record types}. 165: @c JP 166: @item SRFI-9, ?쥳???É·???? 167: ?⥸?塼??ode{srfi-9}?Ç¥??Ý¡??Ȥ???????@ref{Record types}???È¡? 168: @c COMMON 169: 170: @c EN 171: @item SRFI-10, Sharp-comma external form. 172: Built-in. @xref{Read-time constructor}. 173: @c JP 174: @item SRFI-10, Sharp-comma????Õ¥?????Ȥ߹??ߤǤ???@ref{Read-time constructor}???È¡? 175: @c COMMON 176: 177: @c EN 178: @item SRFI-11, Syntax for receiving multiple values. 179: Supported by the module @code{srfi-11}. @xref{Let-values}. 180: @c JP 181: @item SRFI-11, ¿????????????ʸ 182: ?⥸?塼??ode{srfi-11}?Ç¥??Ý¡??Ȥ???????@ref{Let-values}???È¡? 183: @c COMMON 184: 185: @c EN 186: @item SRFI-13, String library 187: Supported by the module @code{srfi-13}. @xref{String library}. 188: (Some of SRFI-13 procedures are built-in). 189: @c JP 190: @item SRFI-13, ʸ?????Ö¥? 191: ?⥸?塼??ode{srfi-13}?Ç¥??Ý¡??Ȥ???????@ref{String library}???È¡? 192: (SRFI-13?μ????Τ????Ĥ???Ȥ߹??ߤˤʤäƤ??Þ¤???) 193: @c COMMON 194: 195: @c EN 196: @item SRFI-14, Character-set library 197: Character-set object and a few SRFI-14 procedures are built-in. 198: @xref{Character set}. 199: Complete set of SRFI-14 is supported by the module @code{srfi-14}. 200: @xref{Character-set library}. 201: @c JP 202: @item SRFI-14, ʸ???Υ饤?Ö¥? 203: ʸ???È´????RFI-14??????Ȥ߹??ߤˤʤäƤ??Þ¤??? 204: @ref{Character set}???È¡?SRFI-14?δ???Ê¥??Ý¡??Ȥϥ⥸?塼??ode{srfi-14} 205: ??󶡤??????Þ¤???@ref{Character-set library}???È¡? 206: @c COMMON 207: 208: @c EN 209: @item SRFI-16, Syntax for procedures of variable arity (case-lambda) 210: Built-in. @xref{Making Procedures}. 211: @c JP 212: @item SRFI-16, ??????³????ʸ (case-lambda) 213: ??ß¹??ߤǤ???@ref{Making Procedures}???È¡? 214: @c COMMON 215: 216: @c EN 217: @item SRFI-17, Generalized set! 218: Built-in. @xref{Assignments}. 219: @c JP 220: @item SRFI-17, ???????줿 set! 221: ??ß¹??ߤǤ???@ref{Assignments}???È¡? 222: @c COMMON 223: 224: @c EN 225: @item SRFI-18, Multithreading support 226: Some SRFI-18 features are built-in, and the rest is in @code{gauche.threads} 227: module. @xref{Threads}. 228: @c JP 229: @item SRFI-18, ?Þ¥??????ɤΥ??Ý¡????????Ĥ???RFI-18?ε?ǽ??Ȥ߹??ߤǤ??ê¡¢???Ĥ?API??@code{gauche.threads}?⥸?塼?????????????@ref{Threads}???È¡? 230: @c COMMON 231: 232: @c EN 233: @item SRFI-19, Time Data Types and Procedures. 234: Time data type is Gauche built-in (@xref{Time}). 235: Complete set of SRFI-19 is supported by the module @code{srfi-19}. 236: @xref{Time data types and procedures}. 237: @c JP 238: @item SRFI-19, ???֥ǡ????η??ȼ??? 239: ???֤Υǡ???????auche??ß¹??ߤǤ?(@ref{Time}?????? 240: SRFI-19?δ???Ê¥??Ý¡??Ȥϥ⥸?塼??ode{srfi-19}??󶡤??????Þ¤??? 241: @ref{Time data types and procedures}???È¡? 242: @c COMMON 243: 244: @c EN 245: @item SRFI-22, Running Scheme scripts on Unix 246: Supported. @xref{Writing Scheme scripts}. 247: @c JP 248: @item SRFI-22, UNIX ?? Scheme ???????Ȥμ¹????Ý¡??Ȥ??????Þ¤???@ref{Writing Scheme scripts}???È¡? 249: @c COMMON 250: 251: @c EN 252: @item SRFI-23, Error reporting mechanism. 253: Built-in. @xref{Signalling exceptions}. 254: @c JP 255: @item SRFI-23, ???顼??𵡹? 256: ??ß¹??ߤǤ???@ref{Signalling exceptions}???È¡? 257: @c COMMON 258: 259: @c EN 260: @item SRFI-25, Multi-dimensional array primitives. 261: Supported by the module @code{gauche.array}, which defines 262: superset of SRFI-25. @xref{Arrays}. 263: @c JP 264: @item SRFI-25, ¿???????Î¥×¥??Æ¥????⥸?塼??ode{gauche.array}????SRFI-25?ξ??ß´????ʤäƤ??Þ¤???@ref{Arrays}???È¡? 265: @c COMMON 266: 267: @c EN 268: @item SRFI-26, Notation for specializing parameters without currying. 269: As an autoloaded macro. @xref{Making Procedures}. 270: @c JP 271: @item SRFI-26, ???꡼??????????Ñ¥???????ü첽??Ë¡ 272: ?????È¥í¡¼?ɤ????Þ¥???????????????Þ¤???@ref{Making Procedures}???È¡? 273: @c COMMON 274: 275: @c EN 276: @item SRFI-27, Sources of Random Bits. 277: Supported by the module @code{srfi-27}. @xref{Sources of random bits}. 278: @c JP 279: @item SRFI-27, ??????åȤΥ????? 280: ?⥸?塼??ode{srfi-27}?Ç¥??Ý¡??Ȥ???????@ref{Sources of random bits}???È¡? 281: @c COMMON 282: 283: @c EN 284: @item SRFI-28, Basic format strings. 285: Gauche's built-in @code{format} procedure is a superset of 286: SRFI-28 @code{format}. @xref{Output}. 287: @c JP 288: @item SRFI-28, ??Õ¥????ޥå????auche??ß¹??ߤ?code{format}??SRFI-28?Τ??ξ??ß´????ʤäƤ??Þ¤???@ref{Output}???È¡? 289: @c COMMON 290: 291: @c EN 292: @item SRFI-29, Localization 293: Supported by the module @code{srfi-29}. 294: @xref{Localization}. 295: @c JP 296: @item SRFI-29, ??è²½ 297: ?⥸?塼??ode{srfi-29}?Ç¥??Ý¡??Ȥ??????? 298: @ref{Localization}???È¡? 299: @c COMMON 300: 301: @c EN 302: @item SRFI-30, Nested multi-line comments. 303: Supported by the native reader. @xref{Lexical structure}. 304: @c JP 305: @item SRFI-30, ?Í¥??Ȥ???Ê£????????Í¥??Æ¥??֤Υ꡼??Ç¥??Ý¡??Ȥ??????Þ¤???@ref{Lexical structure}???È¡? 306: @c COMMON 307: 308: @c EN 309: @item SRFI-31, A special form rec for recursive evaluation 310: Defined as an autoloaded macro. @xref{Binding constructs}. 311: @c JP 312: @item SRFI-31, ?Ƶ?ɾ??Ѥ?ü???????ec 313: ?????È¥í¡¼?ɤ????Þ¥???????????????Þ¤???@ref{Binding constructs}???È¡? 314: @c COMMON 315: 316: @c EN 317: @item SRFI-34, Exception Handling for Programs 318: Built-in. @xref{Exceptions}. 319: (However, Gauche implements srfi-18's semantics of @code{raise} literally, 320: which differs slightly from srfi-34's. This may be changed in future.) 321: @c JP 322: @item SRFI-34, ?×¥í¥°????ã³°?? 323: ??ß¹??ߤǤ???@ref{Exceptions}???È¡? 324: (â????Gauche??code{raise}?˴ؤ??Ƥ?rfi-18?Î¥??Þ¥????????? 325: ??õ¤·¤Æ¤??Æ¡?????srfi-34?ȼ㴳?ۤʤ??????????rfi-34?˹????뤫?⤷?????? 326: @c COMMON 327: 328: @c EN 329: @item SRFI-35, Conditions 330: Built-in. @xref{Conditions}. 331: @c JP 332: @item SRFI-35, ????????? 333: ??ß¹??ߤǤ???@ref{Conditions}???È¡? 334: @c COMMON 335: 336: @c EN 337: @item SRFI-36, I/O Conditions 338: Partly supported. @xref{Conditions}. 339: @c JP 340: @item SRFI-36, I/O ????????? 341: ?ʬŪ?Ë¥??Ý¡??Ȥ??????Þ¤?. @ref{Conditions}???È¡? 342: @c COMMON 343: 344: @c EN 345: @item SRFI-37, args-fold: a program argument processor 346: Supported by the module @code{srfi-37}. 347: @xref{A program argument processor}. 348: @c JP 349: @item SRFI-37, args-fold: ?×¥í¥°????? 350: ?⥸?塼??ode{srfi-37}?Ç¥??Ý¡??Ȥ??????? 351: @ref{A program argument processor}???È¡? 352: @c COMMON 353: 354: @c EN 355: @item SRFI-38, External Representation for Data With Shared Structure 356: Built-in. See @ref{Reading data} and @ref{Output}. 357: @c JP 358: @item SRFI-38, ??Í?????Ç¡????γ??ɽ?? 359: ??ß¹??ߤǤ???@ref{Reading data}??ref{Output}???È¡? 360: @c COMMON 361: 362: @c EN 363: @item SRFI-39, Parameter objects 364: Supported by the module @code{gauche.parameter}. 365: @xref{Parameters}. 366: @c JP 367: @item SRFI-39, ?Ñ¥????????Ö¥????????⥸?塼??ode{gauche.parameter}?Ç¥??Ý¡??Ȥ??????? 368: @ref{Parameters}???È¡? 369: @c COMMON 370: 371: @c EN 372: @item SRFI-40, A Library of Streams 373: Supported by the module @code{util.stream}. 374: @xref{Stream library}. 375: @c JP 376: @item SRFI-40, ???ȥ꡼?????Ö¥? 377: ?⥸?塼??ode{util.stream}?Ç¥??Ý¡??Ȥ??????Þ¤??? 378: @xref{Stream library}. 379: @c COMMON 380: 381: @c EN 382: @item SRFI-42, Eager comprehensions 383: Supported by the module @code{srfi-42}. 384: @xref{Eager comprehensions}. 385: @c JP 386: @item SRFI-42, ?????????ɽ?? 387: ?⥸?塼??ode{srfi-42}?Ç¥??Ý¡??Ȥ??????? 388: @ref{Eager comprehensions}???È¡? 389: @c COMMON 390: 391: @c EN 392: @item SRFI-43, Vector library 393: Supported by the module @code{srfi-43}. 394: @xref{Vector library}. 395: @c JP 396: @item SRFI-43, ?Ù¥????饤?Ö¥? 397: ?⥸?塼??ode{srfi-43}?Ç¥??Ý¡??Ȥ??????? 398: @ref{Vector library}???È¡? 399: @c COMMON 400: 401: @c EN 402: @item SRFI-45, Primitives for Expressing Iterative Lazy Algorithms 403: Built-in. 404: @xref{Delayed evaluation}. 405: @c JP 406: @item SRFI-45, È¿?Ū Lazy ???르?ꥺ????????Ø¿??ß¹??ߤǤ??? 407: @xref{Delayed evaluation}. 408: @c COMMON 409: 410: @c EN 411: @item SRFI-55, require-extension 412: Supported as an autoloaded macro. 413: @xref{Requiring extensions}. 414: @c JP 415: @item SRFI-55, require?γ?? 416: ?????È¥í¡¼?É¥Þ¥??????Æ¥??Ý¡??Ȥ??????? 417: @ref{Requiring extensions}???È¡? 418: @c COMMON 419: 420: @c EN 421: @item SRFI-61, A more general @code{cond} clause 422: Supported natively. @xref{Conditionals}. 423: @c JP 424: @item SRFI-61, ????Ū??code{cond}? 425: ????ߤǤ???@ref{Conditionals}???È¡? 426: @c COMMON 427: 428: @c EN 429: @item SRFI-62, S-expression comments 430: Supported by the native reader. @xref{Lexical structure}. 431: @c JP 432: @item SRFI-62, S?????????Í¥??Æ¥??֤Υ꡼??Ç¥??Ý¡??Ȥ??????Þ¤???@ref{Lexical structure}???È¡? 433: @c COMMON 434: 435: @c EN 436: @item SRFI-87, @code{=>} in case clauses 437: Supported natively. @xref{Conditionals}. 438: @c JP 439: @item SRFI-87, case??Ǥ?code{=>} 440: ????ߤǤ???@ref{Conditionals}???È¡? 441: @c COMMON 442: 443: @end table 444: 445: @node Multibyte Strings, Multibyte scripts, Standard conformance, Concepts 446: @section Multibyte Strings 447: @c NODE ?Þ¥??Ð¥??????@c EN 448: Traditionally, a string is considered as a simple array of bytes. 449: Programmers tend to imagine a string as a simple 450: array of characters (though a character may occupy more than one byte). 451: It's not the case in Gauche. 452: @c JP 453: ?????ʸ??ñ?ʤ????Ȥ?????ư????Ƥ??Þ¤????? 454: ???Τ???ʸ??????Ȥ???褦?ˤʤäƤ????ñ??ʸ????Ǥ????ͤ???????Ǥ????? 455: Gauche?ˤ????Ƥϡ??????ǤϤ???????@c COMMON 456: 457: @c EN 458: Gauche supports @emph{multibyte string} natively, 459: which means characters are represented by variable number of bytes 460: in a string. Gauche retains semantic compatibility of 461: Scheme string, so such details can be hidden, but it'll helpful 462: if you know a few points. 463: @c JP 464: Gauche???Ū??emph{?Þ¥??Ð¥??????ò¥µ¥Ý¡??Ȥ??Þ¤??? 465: ???ʤ???ʸ??????????Ð¥??È¿?????Ƥ??Þ¤???Scheme????????Æ¥??֤Υ??Þ¥????????ݤ????????Ç¡? 466: ?ܺ٤òµ¤¤Ë¤??ʤ??Ǥ??í¥°???Ͻñ¤±¤Þ¤????? 467: ???ˤ????뤤???Ĥ?????äƤ??????Û¤???????Ǥ??礦?? 468: @c COMMON 469: 470: @c EN 471: A string object keeps a type tag and a pointer to the storage 472: of the string body. The storage of the body is managed in a sort of 473: ``copy-on-write'' 474: way---if you take substring, e.g. using directly by @code{substring} 475: or using regular expression matcher, or even if you copy a string 476: by @code{copy-string}, the underlying storage is shared 477: (the ``anchor'' of the string is different, so the copied string 478: is not @code{eq?} to the original string). 479: The actual string is copied only if you destructively modify it. 480: @c JP 481: ʸ???Ö¥??????ȤϷ????????????ؤΥݥ??󥿤????Þ¤??? 482: ʸ????Ï¡?opy-on-write?????Þ¤??????ʤ???@code{substring} 483: ????ɽ????ä?????????????ê¡¢???뤤???????????Ô¡????????? 484: ʸ???Ö¥??????Ȥ??Τ???̤ˤĤ????Þ¤?????ʸ????϶?Í???????? 485: ʸ??????ѹ????????ˤΤߡ?ʸ????????Ô¡????????? 486: @c COMMON 487: 488: @c EN 489: Consequently the algorithm like pre-allocating a string by 490: @code{make-string} and filling it with @code{string-set!} 491: becomes @emph{extremely} inefficient in Gauche. Don't do it. 492: (It doesn't work with mulitbyte strings anyway). 493: Sequential access of string is much more efficient 494: using @emph{string ports} (@xref{String ports}). 495: @c JP 496: ???????äơ?@code{make-string}?Ǥ???????????????餫???ᥢ?í¥±???????Ƥ?????@code{string-set!}?ǽ?????Ô¤??褦?Ê¥??르?ꥺ?? 497: Gauche?Ǥ??˸??????ʤ????????Τ褦?Ê¥??르?ꥺ???Ȥ??????????Ǥ??礦?? 498: (???Τ褦?Ê¥??르?ꥺ???Þ¥??Ð¥?????????????????????? 499: ʸ????????Ô¤?????emph{string ports}????Τ? 500: ??????Ë¡?Ǥ? (@ref{String ports}?????? 501: @c COMMON 502: 503: @c EN 504: String search primitives such as @code{string-scan} (@xref{String utilities}) 505: and regular expression matcher (@xref{Regular expression}) 506: can return a matched string directly, without 507: using index access at all. 508: @c JP 509: @code{string-scan} (@ref{String utilities}???? ????ɽ?? 510: (@ref{Regular expression}???? ?ʤ???????÷¤¹¤????Æ¥??֤ϡ? 511: ????Ã¥?????????˰?????ʸ??ľ???????Ȥ??Ǥ??Þ¤??? 512: @c COMMON 513: 514: @c EN 515: You can choose @emph{internal} encoding scheme at the time of compiling 516: Gauche. At runtime, a procedure @code{gauche-character-encoding} 517: can be used to query the internal encoding. Currently, the following 518: internal encodings are supported. 519: @c JP 520: Gauche?Î¥???????Ë¡?ʸ??mph{?????󥳡??Ç¥?????ò¤¹¤ë¤³?Ȥ??Ǥ??Þ¤??? 521: ?¹Ի??˼???@code{gauche-character-encoding}?ˤ??Ƥɤ?????󥳡??Ç¥????Ç¥?????뤵?줿????뤳?Ȥ???????? 522: ???ΤȤ??í¡¢?ʲ??Î¥??󥳡??Ç¥??ó¥°¤????Ý¡??Ȥ??????Þ¤??? 523: @c COMMON 524: 525: @table @code 526: @item euc-jp 527: @c EN 528: EUC-JP encoding of ASCII, JIS X 0201 kana, JIS X 0212 and JIS X 0213:2000 529: Japanese character set. 530: @c JP 531: ASCII??JIS X 0201???Ê¡?JIS X 0212?Ú¤?IS X 0213:2000ʸ????UC-JP 532: ???󥳡??Ç¥???@c COMMON 533: @item sjis 534: @c EN 535: Shift-JIS encoding of JIS X 0201 kana and JIS X 0213:2000 536: Japanese character set. For source-code compatibility, the character 537: code between 0 and 0x7f is mapped to ASCII. 538: @c JP 539: JIS X 0201???ʵڤ?IS X 0213:2000ʸ????hift-JIS???󥳡??Ç¥??ó¥°¡? 540: ???????????ɤθߴ???Τ??ᡢʸ?ú¥³¡¼??????7f??ϰϤ?IS X 0201 roman 541: ?ǤϤʤ?ASCII?˥ޥåפ??????? 542: @c COMMON 543: @item utf-8 544: @c EN 545: UTF-8 encoding of Unicode. 546: @c JP 547: Unicode??TF-8???󥳡??Ç¥??ó¥°¡? 548: @c COMMON 549: @item none 550: @c EN 551: 8-bit fixed-length character encoding, with the code between 0 and 0x7f 552: matches ASCII. It's up to the application to interpret the string 553: with certain character encodings. 554: @c JP 555: 8?ӥåȸ????????????Ç¥??ó¥°¡?ʸ?ú¥³¡¼??????7f??ϰϤ?SCII???ߤʤ??Þ¤???ʸ???ɤΥ??󥳡??Ç¥??󥰤Ȥ??Ʋ???뤫?Ï¥??ץꥱ??????????Ǥ??? 556: @c COMMON 557: @end table 558: 559: @c EN 560: Conversions from other encoding scheme is provided 561: as a special port. @xref{Character code conversion}, for details. 562: @c JP 563: ¾??????????Ç¥??ó¥°¤?????????̤ʥݡ??Ȥ?äƹԤ??Þ¤??? 564: @ref{Character code conversion} ?ò»²¾È¤??Ʋ??????? 565: @c COMMON 566: 567: @c EN 568: The way to specify the encoding of source programs will be 569: explained in the next section. 570: @c JP 571: ???????×¥í¥°???Î¥??󥳡??Ç¥??ó¥°¤?ꤹ??Ë¡?ˤĤ??Ƥ????ξϤ?????Þ¤??? 572: @c COMMON 573: 574: @node Multibyte scripts, Case-sensitivity, Multibyte Strings, Concepts 575: @section Multibyte scripts 576: @c NODE ?Þ¥??Ð¥??È¥??????? 577: @c EN 578: You can use characters other than @code{us-ascii} not only in 579: literal strings and characters, but in in commens, symbol names, 580: literal regular expressions, and so on. 581: @c JP 582: ????ʸ??ʸ???ˤ⡢?????È¡???????? 583: ???????ɽ???ʤ?Í¡??ʲս???@code{us-ascii}?ʳ??????Ȥ????Ȥ??Ǥ??Þ¤??? 584: @c COMMON 585: 586: @c EN 587: So far, Gauche treats any characters other than @code{us-ascii} 588: as symbol constituent characters. Unicode defines more than dozen 589: "space" characters, though, and they will be treated as whitespace 590: characters in future. So it's better to avoid those characters 591: (except in the strings, regexps and characters) for the time being. 592: @c JP 593: ???ޤΤȤ??í¡¢Gauche??code{us-ascii}?ʳ???????Æ¡?????? 594: ??????????ư????Þ¤???â????Unicode?Ͻ???Ρֶ??????????Ƥ??ê¡¢????Ϥ?????????í¥°??????Ȥ??ư??????????ʤ????礦?????äƸ??ߤΤȤ???????????????(ʸ?????ɽ????ʸ???βս???????Ƥ????Τ?????Ǥ??礦?? 595: @c COMMON 596: 597: @c EN 598: By default, Gauche assumes a Scheme program is written in 599: its internal character encoding. It is fine as far as you're writing 600: scripts to use your own environment, but it becomes a problem if 601: somebody else tries to use your script and finds out you're using 602: different character encoding than his/hers. 603: @c JP 604: ?Ç¥Õ¥????Ǥϡ?Gauche??cheme?×¥í¥°????che???ʸ???????Ç¥??ó¥°¤??ñ¤«¤??????ΤȤ??ư????Þ¤???????????ʬ?ǽñ¤¤¤????????Ȥ?????Ķ??????????ʤ齽ʬ?Ǥ????????????????Ç¥??ó¥°¤???褦????????뤵?줿?Ķ??Ç¥??????Ȥ?餻??????????Ȥʤ????? 605: @c COMMON 606: 607: @c EN 608: So, if Gauche finds a comment something like the following within 609: the first two lines of the program source, it assumes the rest of 610: the source code is written in @code{<encoding-name>}, and does 611: the appropriate character encoding conversion to read the source code: 612: @c JP 613: ?????Ç¡?Gauche?Ï¡????Τ褦?Ê¥????Ȥ??×¥í¥°?????????????ɤ?2??ܤޤǤ˸??줿???????????????ɤλĤ??ʬ??@code{<encoding-name>}????ꤵ?????󥳡??Ç¥??󥰤ǽñ¤«¤??????ΤȤ??Æ¡?ɬ??ʤ? 614: Ŭ??Ê¥??󥳡??Ç¥???Ñ´?????Þ¤??? 615: @c COMMON 616: @example 617: ;; coding: <encoding-name> 618: @end example 619: 620: @c EN 621: More precisely, a comment in either first or second line that matches 622: a regular expression @code{#/coding[:=]\s*([\w.-]+)/} is recognized, 623: and the first submatch is taken as an encoding name. 624: If there are multiple matches, only the first one is effective. 625: The first two lines must not contain characters other than us-ascii 626: in order for this mechanism to work. 627: @c JP 628: ????Τˤϡ?1??ܤޤ?????ܤΥ????Ȥǡ? 629: ???ɽ??@code{#/coding[:=]\s*([\w.-]+)/}?˥ޥå?????Τ????ä????Ë¡? 630: ?ǽ??ʬ?ޥå?????󥳡??Ç¥?????Ȥ?????????????? 631: Ê£??ޥå?????ä????Ϻǽ?????Í???????? 632: ???Υᥫ?Ë¥????????뤿???Ï¡??ǽ?2?Ô°??us-ascii?ʳ??????Þ¤????褦?ˤ??Ʋ??????? 633: @c COMMON 634: 635: @c EN 636: The following example tells Gauche that the script is written 637: in EUC-JP encoding. Note that the string "@code{-*-}" around the coding 638: would be recognized by Emacs to select the buffer's encoding 639: appropriately. 640: @c JP 641: ????м?????Ï¡?Gauche?Ï¥??????Ȥ?euc-jp?ǽñ¤«¤??????Τ?ǧ?????Þ¤???coding??????Ϥ?@code{-*-}"?Ï¡?Emacs?? 642: ?Хåե??Î¥??󥳡??Ç¥??ó¥°¤?Ú¤??ꤹ???˻Ȥ??Þ¤??? 643: @c COMMON 644: 645: @example 646: #!/usr/bin/gosh 647: ;; -*- coding: euc-jp -*- 648: 649: ... script written in euc-jp ... 650: @end example 651: 652: @c EN 653: Internally, the handling of this @emph{magic comment} is done by 654: a special type of port. See @ref{Coding-aware ports} for the 655: details. See also @ref{Loading Scheme file} for how to disable 656: this feature. 657: @c JP 658: ???Ǥϡ?????ü??????Ȥν????̤ʥݡ??Ȥˤ????Ô¤??Ƥ??Þ¤????ܺ٤?ref{Coding-aware ports}?ò»²¾È¤??Ʋ??????? 659: ?Þ¤??????ν???????褦?ˤ???Ë¡?ˤĤ??Ƥ?@ref{Loading Scheme file}?ò»²¾È¤??Ʋ??????? 660: @c COMMON 661: 662: @node Case-sensitivity, Integrated Object System, Multibyte scripts, Concepts 663: @section Case-sensitivity 664: @c NODE ?ʸ????? 665: 666: @c EN 667: Historically, most Lisp-family languages are case-insensitive 668: for symbols. Scheme is no exception and R5RS defines symbols are 669: read in case-insensitive way. (Note that symbols are case-sensitive 670: internally even in R5RS Scheme; case-insensitivity is about readers.) 671: @c JP 672: Lisp?Ϥθ???????Ë¥?????ʸ????????Ƥ??Þ¤???????? 673: Scheme?⤽????????Ǥ??ê¡¢R5RS?Ǥ⥷?????ß¹??Þ¤????????????ò¤·¤Ê¤???????????Þ¤???(â????R5RS??ϰ?????????Ǥ??ʸ????????뤳?ȤˤʤäƤޤ??? 674: ????????Ȥ??Ƥ?????ɤ߹??ß»??????????) 675: @c COMMON 676: 677: @c EN 678: However, nowadays programming is hardly completed in one language. 679: When you have to interact with other languages that distinguish uppercase 680: and lowercase characters, it is desirable that Scheme distinguishes them 681: as well. 682: @c JP 683: ?????????ߤǤϡ??×¥í¥°???ó¥°¤????θ?????뤹?뤳?Ȥ????ˤ???????¾?θ?????󥿥ե?????????ç¡¢Scheme¦?Ǥ?ʸ????????????????Ƥ???????????Ǥ??? 684: @c COMMON 685: 686: @c EN 687: So Gauche has two modes in reading and writing symbols. 688: @emph{By default, Gauche reads and writes symbols in case-sensitive manner}. 689: This behavior doesn't conform R5RS. 690: @c JP 691: ??????auche?Ǥϡ????????ß¹??ߤȽñ¤½Ð¤????ĤΥ⡼?ɤ?Õ¤??Þ¤????? 692: @emph{?Ç¥Õ¥????Υ⡼?ɤǤϡ?Gauche?Υ꡼??ȥ饤???Ï¥?????ʸ????????Þ¤?}?? 693: ???Τդ????ϸ?Ì©?ˤ?5RS?˽????Þ¤???@c COMMON 694: 695: @example 696: ; @r{In case-sensitive mode (default)} 697: (eq? 'a 'A) @result{} #f ; #t @r{in R5RS} 698: (symbol->string 'ABC) @result{} "ABC" 699: (symbol->string 'abc) @result{} "abc" 700: (display (string->symbol "ABC")) @result{} @r{writes} ABC 701: (display (string->symbol "abc")) @result{} @r{writes} abc 702: @end example 703: 704: @c EN 705: You can make Gauche case-insensitive by giving @code{-fcase-fold} 706: command-line option to the @code{gosh} interpreter (@xref{Invoking Gosh}). 707: In this mode, the reader folds uppercase characters in symbols to lowercase 708: ones. If a symbol name contains uppercase characters, it is written 709: out using |-escape (@xref{Symbols}). 710: @c JP 711: @code{gosh}???󥿥ץ꥿?ε?ư????code{-fcase-fold}???Þ¥?饤???Í¿??????Gauche???????????ʤ??⡼?ɤ????Þ¤? (@ref{Invoking Gosh}?????? 712: ???Υ⡼?ɤǤϡ??꡼??Ï¥??????ß¹??ߤκݤ????ʸ???????Þ¤??? 713: ?ʸ??????륷????ؤ??Ƥϡ?`|' ʸ?????????פ????ñ¤½Ð¤????? 714: (@ref{Symbols}?????? 715: @c COMMON 716: 717: @example 718: ; @r{In case-insensitive mode (with -fcase-fold option)} 719: (eq? 'a 'A) @result{} #t 720: (symbol->string 'ABC) @result{} "abc" 721: (symbol->string 'abc) @result{} "abc" 722: (display (string->symbol "ABC")) @result{} @r{writes} |ABC| 723: (display (string->symbol "abc")) @result{} @r{writes} abc 724: @end example 725: 726: @c EN 727: Right now, there's no way to switch these two modes back and forth 728: inside the interpreter. 729: @c JP 730: ???ΤȤ??í¡¢???󥿥ץ꥿??椫????Υ⡼?ɤ?????뤳?ȤϤǤ??Þ¤???@c COMMON 731: 732: 733: @node Integrated Object System, Module system, Case-sensitivity, Concepts 734: @section Integrated Object System 735: @c NODE ??礵?줿???Ö¥??????È¥????Æ¥?@c EN 736: Gauche has a STklos-style object system, similar to CLOS. 737: If you have used some kind of object oriented (OO) languages, 738: you'll find it easy to understand the basic usage: 739: @c JP 740: Gauche??LOS?????????STklos???????????Ö¥??????È¥????Æ¥?????Þ¤??? 741: ???ʤ??????餫?Î¥??Ö¥??????Ȼظ?(OO)????Ȥä????Ȥ??????? 742: ????ʻȤ???Ï´???ˤ狼?????礦?? 743: @c COMMON 744: @example 745: @c EN 746: ;; @r{Defines a class point, that has x and y coordinate} 747: @c JP 748: ;; @r{x, y??????oint???饹??? 749: @c COMMON 750: (define-class point () 751: ((x :init-value 0) 752: (y :init-value 0)) 753: ) 754: 755: (define-method move ((p point) dx dy) 756: (inc! (slot-ref p 'x) dx) 757: (inc! (slot-ref p 'y) dy)) 758: 759: (define-method write-object ((p point) port) 760: (format port "[point ~a ~a]" 761: (slot-ref p 'x) 762: (slot-ref p 'y))) 763: @end example 764: 765: @c EN 766: However, if you are familiar with mainstream OO languages but new to CLOS-style 767: object system, Gauche's object system may look strange 768: