何时为静态数组评估长度? [英] When is Length evaluated for a static array?

查看:124
本文介绍了何时为静态数组评估长度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

type
TMyArray =数组[0..255]的整数;

var
Arr:TMyArray;

....

Writeln(Length(Arr));

何时长度()上下文,当传递一个静态数组?是否在运行时或编译时进行评估?

解决方案


什么时候是 Length()在此上下文中传递静态数组时?


在编译时进行评估,因此不会运行开销。


type
  TMyArray = array [0..255] of Integer;

var
  Arr: TMyArray;

....

Writeln(Length(Arr));

When is Length() evaluated in this context, when passed a static array? Is it evaluated at runtime, or at compile time?

解决方案

When is Length() evaluated in this context, when passed a static array?

It is evaluated at compile time, and therefore carries no runtime overhead.

这篇关于何时为静态数组评估长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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