这里该问题是JavaRanch上的回答: Joel McNary bartender Member # 19124 posted November 17, 2003 10:58 AM -------------------------------------------------------------------------------- I don't know that you can do this syntactically. By eliminating the need to declare types for variables, you have eliminated the ability to enforce how a variable can be used.code: --------------------------------------------------------------------------------a * b-------------------------------------------------------------------------------- is going to be valid no matter if a = 3 or a = "Hello, World"code: --------------------------------------------------------------------------------a=3a="Hello, World"a=someFunction()a*b--------------------------------------------------------------------------------The most that you can do here is have some sort of run-time exception that halts processing and states somethign like, "You cannot multiple "Hello, World" by anything." or something like that.--------------------Joel McNary It takes my kid to raze a village. 我想也许这确是一个不能解决的问题;
我想,编译原理中应该也有这种问题,希望那位编译方面的高手帮我开启一下思路。
Joel McNary
bartender
Member # 19124
posted November 17, 2003 10:58 AM
--------------------------------------------------------------------------------
I don't know that you can do this syntactically. By eliminating the need to declare types for variables, you have eliminated the ability to enforce how a variable can be used.code:
--------------------------------------------------------------------------------a * b--------------------------------------------------------------------------------
is going to be valid no matter if a = 3 or a = "Hello, World"code:
--------------------------------------------------------------------------------a=3a="Hello, World"a=someFunction()a*b--------------------------------------------------------------------------------The most that you can do here is have some sort of run-time exception that halts processing and states somethign like, "You cannot multiple "Hello, World" by anything." or something like that.--------------------Joel McNary
It takes my kid to raze a village. 我想也许这确是一个不能解决的问题;