Deutsch   English   Français   Italiano  
<87plond5te.fsf@nightsong.com>

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

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Paul Rubin <no.email@nospam.invalid>
Newsgroups: comp.lang.forth
Subject: Re: value-flavoured structures
Date: Sat, 28 Sep 2024 10:52:13 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <87plond5te.fsf@nightsong.com>
References: <nnd$61e0ad9a$48ed61c2@b4d945e456041481>
	<c54d153e547438fb9f033b35b270f7cf@www.novabbs.com>
	<vd710j$mrev$2@dont-email.me> <87zfnscypb.fsf@nightsong.com>
	<nnd$61138f06$6ebe7c5e@dd9a69aae34886e2>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 28 Sep 2024 19:52:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="267fe6ba0f2707ae3557a9250710d2a6";
	logging-data="1428502"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18akrQfH9Wbsr+2F12ctSUL"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:sZGB1hpWgbQeFj9vVtbUWMrgofE=
	sha1:x/0S2QkqDpp3oVOPyJideuQj/3Q=
Bytes: 2874

albert@spenarnc.xs4all.nl writes:
> A strong type system is not a problem for embedded applications, as long
> as there is a means to defeat the type system.
> Ada was designed with this in mind, making distinction between safe and
> unsafe modules. Remember that c++ was an afterthought after c that was
> not well designed in the first place.

Rust has unsafe modules but I don't remember Ada having them.  Ada does
have an Unchecked_Conversion function but I don't know where this is
really needed or how well specified it is in the language standard.

Usually in Ada, for low level operations involving things like machine
registers, you'd call subroutines written in assembly language or
similar.  Even in C you sometimes have to do that: any operating system
written in C will contain some asm code.

> Strong typing can be annoying. I remember wasting time passing a filename
> to function that expected a     `const char *` or something, and it is

By filename do you mean a char*, or a counted string (std::string), or
something?  There shouldn't be a problem passing a char* to a function
expecting const char*, since the function simply promises to not modify
the string.  The error is the other direction, passing a const char*
to something that takes a char*, i.e. that doesn't make such a promise.
For std::string there is a builtin that converts to a char* (null
terminated string).

> by no means obvious what you have to do, so you are lured into casting.
> A lot of people do not understand that casting is a means to defeat the
> type system, so that you loose the advantages.

Yes exactly, casting in C++ is a code smell.  I'm not a C++ expert and
haven't written a ton of C++ code, but in what I've written, I don't
remember having needed to cast.