자바스크립트는 동적변수 타입을 지원한다.

일단은 var var_name; 식으로 선언을 할 수 있지만
선언하지 않고 값을 바로 할당해도 동적으로 타입을 결정하기 때문에 변수 타입은 신경쓰지 않아도 된다.

그래도 변수타입중에 신경을 써야 할 것이
undefined 라는 넘이다. 변수를 만들긴 했지만, 내용을 넣지 않았다면 "undefined"로 출력이 된다.

소스 결과
<html>
<script type="text/javascript">
    var ts;
    document.write(ts);
</script>
</html>
 undefined

굳이 var 라는 키워드를 이용해서 변수를 선언하지 않더라도 사용은 가능하지만
일단 변수를 선언하거나 대입하지도 않고 변수를 출력하려고 하면 에러가 발생한다.

소스 결과
<html>
<script type="text/javascript">
    var ts;
    document.write(ts);
    document.write(tt);
</script>
</html>
 undefined

 오류: tt is not defined
 소스 파일: file:///C:/window.html
 행: 5

undefined 는 일반적인 변수에 대한 값이 없음을 나타내고
true / false 는 수치형으로도 사용이 되지만 원칙적으로는 참/거짓에 대한 논리값을 적용한다.
그리고 null은 대소문자를 구분해야 한다.(null 은 object에 대한 값이다)

The typeof operator is used in either of the following ways:

  1. typeof operand
  2. typeof (operand)

Type Result
Undefined "undefined"
Null "object"
Boolean "boolean"
Number "number"
String "string"
Host object (provided by the JS environment) Implementation-dependent
Function object (implements [[Call]] in ECMA-262 terms) "function"
E4X XML object "xml"
E4X XMLList object "xml"
Any other object "object"

typeof true == 'boolean'
typeof null == 'object'

[링크:https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/typeof_Operator]

Logical (Boolean) values, either true or false

null, a special keyword denoting a null value; null is also a primitive value.
Because JavaScript is case-sensitive, null is not the same as Null, NULL, or
any other variant l undefined, a top-level property whose value is undefined; undefined is also a primitive value

Basic Data types


[링크 : https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript 객체출력  (8) 2010.07.20
javascript - for / for .. in  (0) 2010.07.18
javascript template  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
Posted by 구차니
html 웹 페이지 상에서 자바 스크립트를 사용할때의 템플릿

<html>
<script type="text/javascript">
function function_name(var1, var2)
{
    // statements
}

</script>
</html>


'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
java script에 관련한 스펙은 ECMA에 정의되어 있다지만 귀차니즘으로 패스 -ㅁ-
가장 아래의 pdf는 웹을 pdf로 바꾼것으로 보이며, 귀찮으면 가장 아래만 다운받아서 보면된다.


[링크 : https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference]

[링크 : http://www.webreference.com/javascript/reference/core/]
[링크 : http://www.webreference.com/javascript/reference/core_ref/contents.html]
[링크 : http://www.osxsux.net/NSCoreJS15.pdf]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
요즘들어 XML 공부 한답시고 시작했는데 Javascript로 빠져들고 있다.
예전에는 c만을 경배하다 보니 javascript는 무시했는데 생각보다 강력하고, 생각보다 c 와 유사하며, 생각보다 재미있다.

요즘하는 짓꺼리(?)는
javascript로 웹 브라우저 처럼 프레임 문서 만들어서 조작하기.
이게되면은 다음번에는 xml을 이용해서 단어장이나 해봐야지 -ㅁ-

[링크 : http://www.cadvance.org/doc/java]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
JSON - JavaScript Object Notation  (2) 2010.06.07
Posted by 구차니
Programming/C Win32 MFC2010. 7. 4. 23:50
WM_DEVICECHANGE 를 통해서 장치의 변경을 알려준다고 한다.
(머.. 내가 쓸일이 있을려나..)

[링크 : http://blog.kkomzi.net/80] << 요거 참조
[링크 : http://www.codeproject.com/kb/dotnet/devicevolumemonitor.aspx]
[링크 : http://bytes.com/topic/c-sharp/answers/264280-how-can-i-detect-cdrom-usb-device-insertions]

[링크 : http://msdn.microsoft.com/en-us/library/aa363480%28VS.85%29.aspx]
Posted by 구차니
Firefox 즐겨찾기를 내보내는데 json 이라는 확장자가 생겼다.
머하는 확장자인가 해서 찾아 봤더니

JavaScript Object Notation

의 약자이고, 일종의 데이터 교환을 위한 텍스트 파일(이러한 컨셉은 XML과 유사)이다.

[링크 : http://www.json.org/json-ko.html]

'Programming > javascript & HTML' 카테고리의 다른 글

javascript - for / for .. in  (0) 2010.07.18
javascript - 변수 타입  (0) 2010.07.18
javascript template  (0) 2010.07.18
core javascript 문서  (2) 2010.07.18
javascript 관련 링크  (2) 2010.07.18
Posted by 구차니
2010/04/22 - [Programming/C / Win32 / MFC] - 변수인데 왜 operation on 'variable' may be undefined 야?

디스어셈블된 내용중에
lea         edi,[ebp-48h]
이러한 부분이 있었는데 []의 의미를 몰랐다가 이제서야 찾아본다.
[]는 C언어의 []와 유사하게 그 변수의 내용을 메모리 번지로 해석해서 그 번지의 내용을 받아오는 연산자이다.
그러니까 ebp의 내용에서 0x48을 뺀 주소를 edi에 저정하라는 의미이다. (LEA)

LEA--Load Effective Address

Opcode

Instruction

Description

8D /r

LEA r16,m

Store effective address for m in register r16

8D /r

LEA r32,m

Store effective address for m in register r32


[링크 : http://www.intel.com/software/.../instruct32_hh/vc150.htm]

8.9.6 메모리 참조
------------------

  인텔문법에서 메모리를 간접적으로 참조하는 형식은 다음과 같다.
    SECTION:[BASE + INDEX*SCALE + DISP]
  이것은 다음과 같은 AT&T 방식으로 참조된다.
    SECTION:DISP(BASE, INDEX, SCALE)

[링크 : http://vozlt.tistory.com/8]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 언어  (0) 2010.05.03
어셈블리 언어 기본 템플릿  (0) 2010.04.17
Posted by 구차니

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어 기본 템플릿  (0) 2010.04.17
Posted by 구차니
Programming/C Win32 MFC2010. 4. 22. 14:28

#include "stdio.h"

int main(int argc, char *argv[])
{
	int x = 1;
	printf("%d %d %d\n", ++x, x, x++);
	return 0;
}

You're running into two issues:

1. Undefined behavior -- you are attempting to modify the value of an
object more than once between sequence points, and the Standard imposes
no requirement on how to handle that behavior. Basically, any
expression of the forms:

i = i++;
j = k++ * k++;
foo(i,i++,--i);

invoke undefined behavior. Read up on the semantics of the "++" and
"--" operators in an *authoritative* reference (the Standard would
obviously be one, but also K&R2 or H&S5); they don't work the way most
people think they should.

2. Order of evaluation -- AFAIK, there's no requirement that
expressions in a function parameter list be evaluated in any particular
order. At first blush, it *looks* like the arguments were evaluated
from right to left (if x = 1, then x++ evaluates to 1, with the side
effect that x == 2, and ++x evaluates to 3, with the side effect that x
== 3), but given that you've invoked undefined behavior the actual
reason may be something else entirely.

[링크 : http://bytes.com/topic/c/answers/222558-operation-x-may-undefined]

위의 소스를 gcc -Wall 옵션을 주고 컴파일 할 경우에
$ gcc -Wall cc_test.c
cc_test.c: In function ‘main’:
cc_test.c:6: warning: operation on ‘x’ may be undefined
cc_test.c:6: warning: operation on ‘x’ may be undefined
이런 경고가 발생한다.

분명 x는 변수인데, 그에 대한 operation이 정의되지 않았다는게 무슨 말인지 모르겠지만,
아무튼 실행을 하면
$ ./a.out
3 3 1
요런 희한한 결과가 나온다.

아무튼, calling convention과도 연관이 있어 보이는데,
c언어 특성상 right-left 로 push 하므로(가장 위에는 왼쪽 값이 오도록)
가장 먼저들어가는, 오른쪽 x++ 은 1이 들어가고
1을 더해준다음, 다음 명령어를 수행하면서(++x) 한번에 2가 증가하게 되고
그럼으로 인해 x, ++x 순으로 3이 들어가는게 아닐까 생각된다.

아니면 말구?

[링크 : http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html]


winXP SP3 32bit / VC++ 6 에서 해본 결과
 2 1 1


linux / gcc 결과
 3 3 1


objdump를 소스와 함께 디스어셈블 하기 위해서는
gcc -g 옵션으로 디버깅 정보를 주어야 한다.
[링크 : http://wikidocs.net/mybook/1473]


솔찍히 어셈을 몰라서 모르겠다 ㅋㅋ
결론 : 한줄에 ++나 -- 연산자를 중복으로 사용하지 말자.
Posted by 구차니
음.. 역시 모든 언어는 skeleton code를 외우면 상대적으로 익히기가 쉬운듯!
(문득 C언어 배울때 #include <stdio.h> void main() {} 하던 기억이.. OTL)

.386
.MODEL Flat, STDCALL
.DATA
; Your initialized data. <comment>
.DATA?
;Your uninitialized data. <comment>
.CONST
.CODE
label:
    end label

[링크 : http://win32assembly.online.fr/tut1.html]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어  (0) 2010.05.03
Posted by 구차니