<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://trans.onionmixer.net/wiki/index.php?action=history&amp;feed=atom&amp;title=ComputerProgrammingwithGNUSmalltalk%3A3.7</id>
	<title>ComputerProgrammingwithGNUSmalltalk:3.7 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://trans.onionmixer.net/wiki/index.php?action=history&amp;feed=atom&amp;title=ComputerProgrammingwithGNUSmalltalk%3A3.7"/>
	<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=ComputerProgrammingwithGNUSmalltalk:3.7&amp;action=history"/>
	<updated>2026-05-01T17:08:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>https://trans.onionmixer.net/wiki/index.php?title=ComputerProgrammingwithGNUSmalltalk:3.7&amp;diff=2487&amp;oldid=prev</id>
		<title>Onionmixer: CPGS 변수 페이지 추가</title>
		<link rel="alternate" type="text/html" href="https://trans.onionmixer.net/wiki/index.php?title=ComputerProgrammingwithGNUSmalltalk:3.7&amp;diff=2487&amp;oldid=prev"/>
		<updated>2012-09-21T11:53:59Z</updated>

		<summary type="html">&lt;p&gt;CPGS 변수 페이지 추가&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==변수==&lt;br /&gt;
&lt;br /&gt;
{{HighlightBoldBox|스몰토크에서의 변수는, 수학에서의 변수와 매우 흡사합니다. 이 주제를 읽는 동안 마음 속에 기억해두면, 이 개념을 쉽게 상상할 수 있을 것입니다.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
프로그램을 작성하는 동안, 수많은 객체를 씁니다. 객체를 생성하고, 다루고, 파괴합니다. 그러나 객체를 생성한 후, 프로그램의 어떤 부분에서 참조하려 할 때 어떻게 해야 하겠습니까? Human 클래스(스몰토크에서 제공하는 클래스가 아니라, 가상의 클래스라고 생각하시면 됩니다.)를 가지고 있다고 가정하겠습니다. 이 클래스로부터 새로운 객체를 만들 것입니다. 실제 세계의 인간처럼, 각각의 객체는 이름이 있어야, 우리가 그들과 대화할 수 있을 것입니다. 우리가 메시지를 전달하여 대화를 할 것입니다. 메시지를 전달하기 전에 메시지를 받길 원하는 객체를 지정해야 할 것입니다. 객체를 반환하는 표현식이나 객체의 이름으로 그것을 할 수 있습니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Human 인스턴스 Carl을 가지고 있다고 가정하겠습니다. 우리는 그에게 이렇게 메시지를 보낼 수 있습니다.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
Carl tellUsYourLastName&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
여기서 Carl은 Human 인스턴스를 참조합니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
객체에 이름 지어주는 것을 {{HighlightSubscript|지정|assignment}}이라고 합니다. 그리고 지어준 이름을 프로그래밍 용어로 {{HighlightSubscript|변수|variables}}라고 합니다. (변할 변자를 쓰는) 변수라는 용어를 쓰는 이유는, 한 객체만을 참조할 수 있지만, 그것이 언제든지 프로그램의 다른 객체를 가리킬 수 있기 때문입니다. 객체에 이름을 어떻게 지정하는지 배우기 전에, 먼저 왜 그러한 것을 원하게 되는지 얘기해보겠습니다. human 객체를 만들었던 위의 예제같은 경우에는, 아마도 그 변수가 다른 객체를 참조하도록 바꾸길 원치 않을 것입니다. 그러나 다른 예제로, 하루에 식당에 방문한 사람들의 수를 추적하는 프로그램을 가지고 있다고 가정했을 때, 손님이 올 때마다 숫자는 증가할 것입니다. 그렇게 하려면 어떻게 해야 되겠습니까? 먼저 객체 0을 참조하는 변수를 생성합니다. 그리고 손님이 올 때마다 변수를 호출하여, 그 변수가 가리키는 객체를 가져다가, 1을 더하여 변수가 그것을 가리키게합니다. 따라서 매회 손님들이 올 때마다 변수는 다른 객체를 참조할 것입니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
이제 변수 할당 문법을 알아볼 시간입니다. 할당을 하기 전에, 변수를 만들어야 합니다. 변수를 만드는 기본 구조는 다음과 같습니다.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
| aVariable anotherVariable andAnotherVariable |&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
여기 aVariable, anotherVariable 그리고 andAnotherVariable 이라고 이름 붙여진 세 개의 변수를 생성하였습니다. 우리는 파이프 문자 사이에 만들기 원하는 변수 이름을 두었습니다. 변수 이름은 빈 칸으로 구분하였고, 우리가 원하는 만큼 변수를 생성할 수 있습니다. 변수 지정은 다음과 같이 할 수 있습니다.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;smalltalk&amp;quot;&amp;gt;&lt;br /&gt;
aVariableName := anObject&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{HighlightSubscript|지정 연산자|assignment operator}}라고 부르는 연산자는 콜론과 등호 기호를 빈칸 없이 연결하여 구성합니다. 이 연산자는 우측 변의 객체를 좌측 변의 변수에 할당합니다.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
모든 객체는 컴퓨터 메모리의 공간을 차지하도록 생성하며, 변수의 역할은 실제로 객체의 메모리 주소를 가지고 있는 것입니다.&lt;br /&gt;
&lt;br /&gt;
[[Category:ComputerProgrammingwithGNUSmalltalk]]&lt;/div&gt;</summary>
		<author><name>Onionmixer</name></author>
	</entry>
</feed>