在C编程语言中,我在使用任何非声明性/赋值表达式之前对所有语言修订都强制执行前面的变量声明.C++似乎已经放弃了所有版本的这一要求.我也认识到更多现代版本的C也放弃了这个要求,但我还没有使用任何这些标准.
我的问题是:有什么历史原因阻止C语言自由地按需而不是预先声明?
显然,从工程的角度来看,有许多原因可以解释,但对我来说,似乎没有任何一个理由可信.
有没有人有任何好的消息来支持上述任何一个?我完全错过了什么吗?我们可以推测从黎明到黄昏,但我正在寻找好的参考资料.
作为一名拥有大量XML消费和生产经验的开发人员,我以前从未真正与模式交互过.这是第一次真正发生在我身上.
我遇到了一个"功能",我认为它更像是一个记录良好的错误.
使用XDocument.Validate()时,似乎有些情况下,如果文档与指定的模式不匹配,则文档将有效.我觉得这很可能是我理解XSD,XML命名空间和预期验证过程之间关系的一个缺陷.
因此,我向您提交了我的XML示例,我的XSD示例和我的验证代码.
XML - 这本质上是错误的文档.
<?xml version="1.0" encoding="utf-8" ?>
<SuppliesDefinitions
xmlns="http://lavendersoftware.org/schemas/SteamGame/Data/Xml/Supplies.xsd">
<Supply type="Common">
<Information/>
<Ritual/>
<Weapon/>
<Tool count="1"/>
<Tool count="2"/>
<Tool count="3"/>
</Supply>
<Supply type="Uncommon">
<Information/>
<Weapon/>
<Tool count="1"/>
<Tool count="2"/>
<Tool count="3"/>
<Tool count="4"/>
</Supply>
<Supply type="Rare">
<Information/>
<Rune/>
<Weapon/>
<Tool count="2"/>
<Tool count="3"/>
<Tool count="4"/>
</Supply>
</SuppliesDefinitions>
Run Code Online (Sandbox Code Playgroud)
XSD用于验证它.(同样,这是上述XML的WRONG文档)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Encounters"
targetNamespace="http://lavendersoftware.org/schemas/SteamGame/Data/Xml/Encounters.xsd"
elementFormDefault="qualified"
xmlns="http://lavendersoftware.org/schemas/SteamGame/Data/Xml/Encounters.xsd"
xmlns:mstns="http://lavendersoftware.org/schemas/SteamGame/Data/Xml/Encounters.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="ToolType">
<xs:attribute name="count" use="required" type="xs:int"/>
</xs:complexType>
<xs:complexType name="TaskType">
<xs:choice maxOccurs="unbounded" minOccurs="1">
<xs:element name="Weapon"/>
<xs:element name="Information"/>
<xs:element …Run Code Online (Sandbox Code Playgroud)