Deutsch English Français Italiano |
<20240401111844.249@kylheku.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: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Mon, 1 Apr 2024 18:25:54 -0000 (UTC) Organization: A noiseless patient Spider Lines: 69 Message-ID: <20240401111844.249@kylheku.com> References: <uu54la$3su5b$6@dont-email.me> <uu636l$7haj$1@dont-email.me> <20240329084454.0000090f@gmail.com> <uu6om5$cmv8$1@dont-email.me> <20240329101248.556@kylheku.com> <uu6t9h$dq4d$1@dont-email.me> <20240329104716.777@kylheku.com> <uu8p02$uebm$1@dont-email.me> <20240330112105.553@kylheku.com> <uudrfg$2cskm$1@dont-email.me> <87r0fp8lab.fsf@tudado.org> <uuehdj$2hshe$1@dont-email.me> Injection-Date: Mon, 01 Apr 2024 18:25:54 +0200 (CEST) Injection-Info: dont-email.me; posting-host="464ee9ca5191ced3e9304b3dead768a7"; logging-data="2779645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x4YxrutQfla6Ao98trpL+LQknK8mLCIQ=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:YdF2y5cVYFxCmkvoS46fKbZGIUI= Bytes: 4504 On 2024-04-01, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: > On Mon, 01 Apr 2024 06:49:48 -0300 > Johanne Fairchild <jfairchild@tudado.org> wrote: >>Muttley@dastardlyhq.com writes: >> >>> On Sat, 30 Mar 2024 18:46:50 -0000 (UTC) >>> Kaz Kylheku <643-408-1753@kylheku.com> wrote: >>>>(defun get-network-interface-list () >>>> (open-shared-library "iphlpapi.dll") >>>> (let ((blk-size 65536) ;; crude! >>>> (get-adapters-info (foreign-symbol-address "GetAdaptersInfo"))) >>>> (if get-adapters-info >>>> (%stack-block ((blk blk-size)) >>>> (rlet ((len-inout #>ULONG blk-size)) >>>> (if (zerop (ff-call get-adapters-info :address blk >>>> :address len-inout >>>> #>DWORD)) >>>> (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next) >>>> until (%null-ptr-p ptr) >>>> collecting >>>> (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength)) >> >>>> (addr (pref ptr #>IP_ADAPTER_INFO.Address)) >>>> (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName)) >>>> (descr (pref ptr #>IP_ADAPTER_INFO.Description)) >>>> (iplist (pref ptr >>#>IP_ADAPTER_INFO.IpAddressList)) >>>> >>>> (type (pref ptr #>IP_ADAPTER_INFO.Type))) >>>> (list type >>>> (loop for i below alen >>>> collecting (%get-unsigned-byte addr i) >>>> into mac-bytes >>>> finally >>>> (return (mac-bytes-to-string >>mac-bytes))) >>>> >>>> (get-ip-address-list iplist) >>>> (%get-cstring aname) >>>> (%get-cstring descr)))))))))) >>> >>> Ugh. No wonder the language fell out of fashion. Looks like some kind of >>> hacked up Basic. >> >>Fashion and intelligence have never been very good friends. > > Readability of the flow of control matters. God knows whats going on with > all those nested statements. I didn't spend a lot of time on that code in the first place, and have not looked it in over ten years; yet it's trivially easily readable to me. Anyway, it's in a high level language, yet following a linked list of structs obtained from a Win32 function, which the code fetches into a buffer allocated efficiently on the native stack. The whole thing is compiled into native code. CCL's primitives for accessing the C stuff aren't pretty, but they are helpful. It's nice that it has the parsed information about the struct offsets, like #>IP_ADAPTER_INFO.AdapterName. I didn't have to define that anywhere. I remember it was pretty easy to figure the primtiies out from CCL's reference documentation. Easy to write, easy to read a decade later. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca