当 F# 中的类型提供程序发生更改时会发生什么?
观看关于 F# 类型提供商的 Channel 9 的视频后,我想知道有关数据的信息架构更改。唐最后谈到了这一点,但我正在寻找更多细节。
演示让您看起来好像实际上是在按“.”。探索您可以使用哪些类型的数据。例如,在连接到 2008 年美国的犯罪率之后,当您分发应用程序和架构更改时会发生什么?您是否收到运行时类型错误?开发者有责任处理这些错误吗?
此外,这是否会将责任交给类型提供者?
目前,当您下载 .NET 程序集时,您知道它永远不会更改,除非您(手动或通过服务)显式更新它。必须解决不断发展的类型带来的编译错误,但您始终可以推迟升级,直到您准备好进行更改为止。对于类型提供者,您是否必须更加谨慎地针对它们进行编程?
After watching Channel 9's video on F# Type Providers, I'm wondering about data schema changes. Don touched on this a little bit at the end, but I'm looking for more details.
The demo made it look as though you're essentially pressing '.' to explore what kinds of data is available to you. After you link up to, say, crime rates in the US in 2008, what happens when you distribute your application and the schema changes? Do you get runtime type errors? Is it the responsibility of the developer to handle these errors?
Also, does this put the responsibility into the type provider's hands?
Currently when you download a .NET assembly, you know it will never change until you (manually or through a service) explicitly update it. Compile errors from evolving types must be resolved, but you can always hold off the upgrade until you're ready for the change. With type providers, do you have to program more cautiously against them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
响应架构更改是类型提供者的责任,但仅限于开发时。开发应用程序后,将使用类型提供程序并使用编译时的当前架构对其进行编译。
当您使用 Visual Studio 中的类型提供程序时,它可以监视架构更改并通知 Visual Studio IDE 架构已发生更改。我编写了一个 XML 类型提供程序示例来执行此操作,因此当您更改架构(用作示例的 XML 文件)时,您将立即在 VS 中收到错误。我做了一个视频演示(19:40 左右)。
编译程序后,类型提供程序会生成应以编译形式使用的代码(并且类型提供程序在运行时不使用)。这意味着如果架构在运行时发生更改,您将无法对其执行任何操作(开发人员需要做出反应)。如果架构更改是向后兼容的(即向数据库表添加新列),那么您的程序可能仍然可以正常工作。
Responding to the schema changes is the responsibility of the type provider, but only at the development time. Once you develop an application, it gets compiled using the type provider and using the current schema at the time of the compilation.
When you're using type provider from Visual Studio, it can monitor the schema changes and notify the Visual Studio IDE that there has been a change in the schema. I wrote a XML type provider example that does this, so when you change the schema (XML file used as an example), you'll immediately get errors in VS. I did a video demonstration of this (around 19:40).
Once you compile your program, the type provider generates code that should be used in the compiled form (and the type provider is not used at runtime). This means that if the schema changes at runtime, you can't do anything about it (the developer needs to react). If the schema change is backwards-compatible (i.e. add new columns to a DB table), then your program may still work fine though.