How can i make executable guile file to process command line arguments?

2022-08-18 Thread Jacob Hrbek
I have this file which i use to interact with a version controlled 
repository similar to a Makefile.


How can i make it work with e.g. `./file.scm echo wheee` -> Will execute 
the `(define (echo msg) ...)` and output `wheee` in the terminal?


FWIW preferably i want it to work like `./file.scm echo whee build` so 
that it would output `wheee` and then ran the `(define (build) ...)` 
task too..


#!/usr/bin/env sh
exec guile -s "$0" "$@"
!#
;;; This file is used to interact with the project

;;;  [START] TO BE INCLUDED IN A LIBRARY [START]  ;;;

;; Get path to the current filename
(define-public %repo-root (dirname (current-filename)))

;;;  [STOP] TO BE INCLUDED IN A LIBRARY [STOP]  ;;;

;; FIXME-QA(Krey): We need to define an alternative to `(define 
(task)...)` to be more workable and faster to write


;;; Tasks
;; DESIGN(Krey): Build the system configuration
(define (build)
  (system* "guix"
       "system"
       "build"
       (string-append %repo-root "/config.scm")))

;; DESIGN(Krey): Deploy the system configuration on the current system
(define (deploy)
  (system* "guix"
       "system"
       "reconfigure"
       (string-append %repo-root "/config.scm")))

;; DESIGN(Krey): Build the bare minimal image for rockpro64
(define (tools-minimal-rockpro64)
  (system* "guix"
       "system"
       "--system=aarch64-linux"
       "image"
       (string-append %file-root "/config.scm")))

;; Processing of cli arguments
(define (echo msg) (system* "echo" msg))

;; DESIGN(Krey): Expecting to process the command-line args here
;; HOTFIX(Krey): Didn't figure out how to do it yet, so currently 
hard-coding

; deploy

;(quote (cdr (command-line)))
;;(match (command-line) ((_ "build") (build)))



publickey - kreyren@rixotstudio.cz - 1677db82.asc
Description: application/pgp-keys


signature.asc
Description: OpenPGP digital signature


Re: How can i make executable guile file to process command line arguments?

2022-08-18 Thread Olivier Dion via General Guile related discussions
On Thu, 18 Aug 2022, Jacob Hrbek  wrote:
> I have this file which i use to interact with a version controlled 
> repository similar to a Makefile.
>
> How can i make it work with e.g. `./file.scm echo wheee` -> Will execute 
> the `(define (echo msg) ...)` and output `wheee` in the terminal?

You can't directly call your command.  This is because the shebang is
fixed and thus you will always call the same procedure.  But you could
dispatch your commands in your entrypoint.

How about something like this:
--8<---cut here---start->8---
#!/usr/bin/env -S guile --no-auto-compile -e main -s
-*-Scheme-*-
!#

(use-modules
  (ice-9 match))

(define (echo msg)
  (display msg)
  (newline))

(define (usage prog)
  (format (current-output-port)
  "Usage: ~a COMMAND ARGS..."
  prog))

(define (main args)
  (exit
(match (cdr args)
  (("echo" msg . rest) (echo msg) #t)
  (_ (usage (car args)) #f
--8<---cut here---end--->8---



[ANN] Dezyne 2.16.0 released

2022-08-18 Thread Jan Nieuwenhuizen
We are happy to announce Dezyne 2.16 which introduces the `defer'
keyword: A new language concept for implementing an asynchronous
interface.  With defer, the basic semantics are complete.

* About

Dezyne[0] is a programming language and a set of tools to specify,
validate, verify, simulate, document, and implement concurrent control
software.

The Dezyne language has formal semantics expressed in mCRL2[1] developed
at the department of Mathematics and Computer Science of the Eindhoven
University of Technology (TUE[2]).  Dezyne requires that every model is
finite, deterministic and free of deadlocks, livelocks, and contract
violations.  This achieved by means of the language itself as well as by
builtin verification through model checking.  This allows the
construction of complex systems by assembling independently verified
components.

* Summary

Defer replaces dzn.async ports feature that cannot be used in systems
collateral blocking.  The use of dzn.async ports is now deprecated.

Also new in this release: Cleanups to the code generators and model to
model transformations.

See also the documentation .

We will evaluate your reports and track them via the Gitlab
dezyne-issues project[3], see our guide to writing helpful bug
reports[4].

* What's next?

In the next releases we like to see implicit interface constraints,
shared interface state and verification with system scope for
automatically exploring possible traces in a system.

* Future

Looking beyond the next releases: Module-specifications and
data-interfaces.  Hierarchical behaviors.  Support for Model Based
Testing.

Enjoy!
The Dezyne developers.

* Download

  git clone git://git.savannah.nongnu.org/dezyne.git

Here are the compressed sources and a GPG detached signature[*]:
  https://dezyne.org/download/dezyne/dezyne-2.16.0.tar.gz
  https://dezyne.org/download/dezyne/dezyne-2.16.0.tar.gz.sig

Here are the SHA1 and SHA256 checksums:

  91e8d61cdd9333edbd2768c26c187c35ba7e8a6c  dezyne-2.16.0.tar.gz
  6d41b2e671afc629610de8f7ed48dd1799bae08b17bd9455a3b9b684f69524f4  
dezyne-2.16.0.tar.gz

[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact.  First, be sure to download both the .sig file
and the corresponding tarball.  Then, run a command like this:

  gpg --verify dezyne-2.16.0.tar.gz.sig

If that command fails because you don't have the required public key,
then run this command to import it:

  gpg --keyserver keys.gnupg.net --recv-keys 
1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273

and rerun the 'gpg --verify' command.

Alternatively, Dezyne can be installed using GNU Guix[5]:
  guix pull
  guix install dezyne

* NEWS

* Changes in 2.16.0 since 2.15.4
** Language
  - A new keyword `defer' has been introduced.
  - The `dzn.async' ports are now deprecated.
  - Complex boolean and integer expressions are now supported.
** Build
  - The tests for the experimental Scheme code generator are now being
compiled.
  - The tests for the experimental Scheme and JavaScript code generators
now also execute out-of-the-box in a container.
** Code
  - The C++, C#, and experimental Scheme code generators support `defer'.
  - The experimental Scheme code generator now also supports collateral
blocking and thus has full blocking support.
  - The C++ and C# runtime now has a more elegant and efficient
implementation for collateral blocking.
  - The code generators now produce expressions with `&&' and `||' using
courtesy parentheses.  This avoids compiler warnings.
  - The code generators no longer produce unnecessarily parenthesized
and complex expressions.  This also avoids CLANG compiler warnings.
  - The code generators now preserve the top level comment.
** Commands
  - The `dzn' command has a new option: `-t,--transform=TRANS'.  This
makes dzn->dzn transformation avaiable from the command line.
+ New transformations have been added:
  `add-determinism-temporaries`, `inline-functions',
  `simplify-guard-expressions', and `split-complex-expressions'.
+ The `add-explicit-temporaries' transformation now supports complex
  boolean and integer expressions (#67[6]).
** Noteworthy bug fixes
  - Some warnings in the C++ runtime have been fixed and side-stepped.
  - The mCRL2 code generator now generates correct code for an unused
assignment from an action or function call as only statement in a
branch of an if-statement.
  - Shadowing of a variable in a branch of an if-statement is no longer
rejected.
  - The simulator now correctly displays a V-fork compliance error in a
blocking trace.
  - The simulator now correctly handles a trace with foreign provides
triggers.

* Links

[0] https://dezyne.org
[1] https://mcrl2.org
[2] https://tue.nl
[3] https://gitlab.com/groups/dezyne/-/issues
[4] https://dezyne.org/bugreport
[5] https://guix.gnu.org
[6] https://gitlab.com/dezyne/dezyne-issues/-/issues/67

-- 
Jan Nieuwenhuizen   |

Re: How can i make executable guile file to process command line arguments?

2022-08-18 Thread Zelphir Kaltstahl

Hello Jacob,

On 8/18/22 16:01, Jacob Hrbek wrote:
I have this file which i use to interact with a version controlled repository 
similar to a Makefile.


How can i make it work with e.g. `./file.scm echo wheee` -> Will execute the 
`(define (echo msg) ...)` and output `wheee` in the terminal?


FWIW preferably i want it to work like `./file.scm echo whee build` so that it 
would output `wheee` and then ran the `(define (build) ...)` task too..


#!/usr/bin/env sh
exec guile -s "$0" "$@"
!#
;;; This file is used to interact with the project

;;;  [START] TO BE INCLUDED IN A LIBRARY [START]  ;;;

;; Get path to the current filename
(define-public %repo-root (dirname (current-filename)))

;;;  [STOP] TO BE INCLUDED IN A LIBRARY [STOP]  ;;;

;; FIXME-QA(Krey): We need to define an alternative to `(define (task)...)` to 
be more workable and faster to write


;;; Tasks
;; DESIGN(Krey): Build the system configuration
(define (build)
  (system* "guix"
       "system"
       "build"
       (string-append %repo-root "/config.scm")))

;; DESIGN(Krey): Deploy the system configuration on the current system
(define (deploy)
  (system* "guix"
       "system"
       "reconfigure"
       (string-append %repo-root "/config.scm")))

;; DESIGN(Krey): Build the bare minimal image for rockpro64
(define (tools-minimal-rockpro64)
  (system* "guix"
       "system"
       "--system=aarch64-linux"
       "image"
       (string-append %file-root "/config.scm")))

;; Processing of cli arguments
(define (echo msg) (system* "echo" msg))

;; DESIGN(Krey): Expecting to process the command-line args here
;; HOTFIX(Krey): Didn't figure out how to do it yet, so currently hard-coding
; deploy

;(quote (cdr (command-line)))
;;(match (command-line) ((_ "build") (build)))


If you are looking for having command line arguments like --some-flag, 
--my-val=123 and so on, you might want to take a look at the examples in my 
repo: 
https://notabug.org/ZelphirKaltstahl/guile-examples/src/master/command-line-arguments. 
Maybe your use-case can be implemented using such command line arguments, 
instead of having "raw arguments".


Regards,
Zelphir

--
repositories: https://notabug.org/ZelphirKaltstahl




Error in error?

2022-08-18 Thread sidhu1f
According to the guile (version 3.0.7) reference manual, (error "foo
~a" 'bar) should output "foo bar" but instead the output is "foo ~a
bar".  Am I missing something or is there a bug in error?

Regards
sidhu1f