Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=C3=B8j?= Newsgroups: comp.os.vms Subject: Re: Simple Pascal question Date: Sun, 4 Aug 2024 21:00:35 -0400 Organization: A noiseless patient Spider Lines: 62 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 05 Aug 2024 03:00:36 +0200 (CEST) Injection-Info: dont-email.me; posting-host="59342297adf5c5ebfa2d4ee831cf7b5b"; logging-data="321462"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6KL6ZNoHTXhzOd453K1L1//5UmTK5XQk=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:hY2rb1cBNZwaYb7d97vne4ufAB4= Content-Language: en-US In-Reply-To: Bytes: 2846 On 8/4/2024 8:09 PM, Dan Cross wrote: > In article , > Arne Vajhøj wrote: >> On 8/4/2024 8:22 AM, Dan Cross wrote: >>> Interesting, this has become du jour again in modern languages, >>> but those tend to provide access to a `slice` type that provides >>> a window onto the underly array, and implicitly encodes a >>> length (and usually a "capacity"). This makes working with >>> arrays in such languages very convenient. >> >> Different people may have different opinions on what is a modern >> language. > > Designed in this century. That rules out Java. But there are still languages like C#, Scala and Kotlin. >> But a lot of the widely used static typed languages does not >> have any problems with arrays of different lengths as they >> are treated as objects. > > Like I said, modern languages make this a solved problem. But C#, Scala and Kotlin also just allows for passing any length arrays to methods taking an array. >> Like: >> >> public class FlexArray { >> private static void dump(int[] a) { >> for(int v : a) { >> System.out.printf(" %d", v); >> } >> System.out.println(); >> } >> public static void main(String[] args) throws Exception { >> int[] a1 = { 1 }; >> int[] a2 = { 1, 2 }; >> int[] a3 = { 1, 2, 3 }; >> dump(a1); >> dump(a2); >> dump(a3); >> } >> } > > Java arrays are more like the aforementioned slices. I don't think so. Java does not have anything like slices. C# does. C# Span is similar to slices. But C# Span and C# array are far from the same. Arne