Ada中的自定义“图片”属性? [英] Custom 'image attribute in Ada?

查看:96
本文介绍了Ada中的自定义“图片”属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有事。

type Thing is new record
  ...elements...
end record;

我有一个将其字符串化的函数。

I have a function which stringifies it.

function ToString(t: Thing) returns string;

我想告诉Ada将此功能用于 'image ,这样我图书馆的用户就不必考虑使用的是内置类型还是Thing。

I would like to be able to tell Ada to use this function for Thing'image, so that users of my library don't have to think about whether they're using a builtin type or a Thing.

但是,显而易见的语法是:

However, the obvious syntax:

for Thing'image use ToString;

...不起作用。

有没有办法做到这一点?

Is there a way to do this?

推荐答案

我不知道为什么语言不支持此功能,并且我不知道是否有人提出过正式建议(Ada Issue或AI)。 AI12-0020 (Ada 2012的第20条AI)中提到我不认为我们出于技术原因而拒绝它的重要性。

I don’t know why the language doesn’t support this, and I don’t know whether anyone has ever raised a formal proposal that it should (an Ada Issue or AI). The somewhat-related AI12-0020 (the 20th AI for Ada 2012) includes the remark "I don't think we rejected it for technical reasons as much as importance".

您可以看到为什么Ada报告员小组可能认为这相对不重要:您始终可以声明 Image 函数;

You can see why the Ada Rapporteur Group might think this was relatively unimportant: you can always declare an Image function; the difference between

Pkg.Image (V);

Pkg.Typ’Image (V);

不是很大。

这篇关于Ada中的自定义“图片”属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆