Deutsch   English   Français   Italiano  
<v8pbjc$doa$1@reader1.panix.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.os.vms
Subject: Re: Simple Pascal question
Date: Mon, 5 Aug 2024 01:58:04 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <v8pbjc$doa$1@reader1.panix.com>
References: <v8goeh$2b5op$1@dont-email.me> <v8o4h8$2ut3$1@dont-email.me> <v8p58c$gmo$1@reader1.panix.com> <v8p87j$9ptm$3@dont-email.me>
Injection-Date: Mon, 5 Aug 2024 01:58:04 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="14090"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
Bytes: 2974
Lines: 72

In article <v8p87j$9ptm$3@dont-email.me>,
Arne Vajhøj  <arne@vajhoej.dk> wrote:
>On 8/4/2024 8:09 PM, Dan Cross wrote:
>> In article <v8o4h8$2ut3$1@dont-email.me>,
>> Arne Vajhøj  <arne@vajhoej.dk> 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.

Agreed.  Java is not very modern by, er, modern standards.

>But there are still languages like C#, Scala and Kotlin.

Or Rust, Go, Zig, etc.

>>> 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 I said, modern languages solved the problem.

>>> 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.

An array in Java is a pointer and a length.  A slice is a
pointer and a length.  

>C# does.
>
>C# Span is similar to slices. But C# Span and C# array are far from
>the same.

You have some studying to do.  :-)

	- Dan C.