How to rename a procedure and use it

i have this file containing:

(require srfi/31) ;; for 'rec in def.scm
(require srfi/69) ;; Basic hash tables

(require srfi/25) ;; Multi-dimensional Array Primitives
(require srfi/8) ;; Values , receive

(require (rename-in racket/base [for for-racket])) ;; backup original Racket 'for'
;;(define-syntax for-racket (make-rename-transformer #'for))

(require (for-syntax r6rs/private/base-for-syntax)) ;; for macro syntax (for ... : stxparam.rkt identifier-syntax: undefined

(include "def.scm")

(include "array.scm")

(include "declare.scm")
(include "condx.scm")
(include "block.scm")
(include "not-equal.scm")
(include "exponential.scm")
	
(include "while-do-when-unless.scm")
(include "repeat-until.scm")
(include "bitwise.rkt")
(include "modulo.scm")

(include "slice.scm")
       
(include "overload.scm")

(include "set-values-plus.scm")

(include "increment.scm")
(include "for_next_step.scm")



(include "assignment.rkt")
(include "apply-square-brackets.rkt")

i try to rename 'for' because i have a personal version in for_next_step.scm,
but if i try to use it:

Welcome to DrRacket, version 8.9 [cs].
Language: reader "SRFI/SRFI-105.rkt", with debugging; memory limit: 8192 MB.
. Scheme+.rkt:46:20: module: identifier already required
  also provided by: srfi/69 in: hash
> (for-racket ([i '()])
    (error "doesn't get here"))
. . ../../../../../../../../../Applications/Racket v8.9/collects/racket/private/kw.rkt:1263:25: for-racket: undefined;
 cannot reference an identifier before its definition
> 



i searched a lot, find this:

but it does not works, the error is related to the require of (require srfi/69) ;; Basic hash tables

A minimal example that demonstrates the error:

#lang racket/base
;;; test.rkt

(require srfi/69 (rename-in racket/base [for racket-for]))

(racket-for ([i '()])
            (println "Shouldn't get here"))
$ racket test.rkt
test.rkt:3:28: module: identifier already required
  at: hash
  in: racket/base
  also provided by: srfi/69
  location...:
   test.rkt:3:28

To fix: change the use of rename-in, which imports everything in a module, renaming some identifiers, to only-in, which only imports the specified (Optionally renamed) ones.

1 Like

thank you it works now:

;; Scheme+.rkt 

(require srfi/31) ;; for 'rec in def.scm
(require srfi/69) ;; Basic hash tables

(require srfi/25) ;; Multi-dimensional Array Primitives
(require srfi/8) ;; Values , receive

(require (only-in racket/base [for for-racket])) ;; backup original Racket 'for'

(require (for-syntax r6rs/private/base-for-syntax)) ;; for macro syntax (for ... : stxparam.rkt identifier-syntax: undefined

(include "def.scm")

(include "array.scm")

(include "declare.scm")
(include "condx.scm")
(include "block.scm")
(include "not-equal.scm")
(include "exponential.scm")
	
(include "while-do-when-unless.scm")
(include "repeat-until.scm")
(include "bitwise.rkt")
(include "modulo.scm")

(include "slice.scm")
       
(include "overload.scm")

(include "set-values-plus.scm")

(include "increment.scm")
(include "for_next_step.scm")



(include "assignment.rkt")
(include "apply-square-brackets.rkt")

;; include afer overloadind declarations when any
;;(include "scheme-infix.rkt")


partial code:

(for-racket ([i (in-range {n - 2})])
		;(for ({i <+ 0} {i < n - 2} {i <- i + 1})

		     ;; calcul des stimuli reçus par la couche cachée d'indice i+1 à-partir de la précedente

		     ;; create an array with 1 in front for the bias coefficient
		    
		     {z_1 <- #(1) + z[i]}

		     {z̃[i + 1] <- M[i] * z_1} ; z̃ = matrix * vector , return a vector

		     (display "z̃[i + 1] = ") (display {z̃[i + 1]}) (newline)

		     ; calcul des réponses des neurones cachés
		     ;
		     ; i use Neoteric Expression :https://sourceforge.net/p/readable/wiki/Rationale-neoteric/
		     ; example: {map(sin '(0.2 0.7 0.3))}
		     ; '(0.19866933079506122 0.644217687237691 0.29552020666133955)
		     ;
		     ; i use Neoteric Expression to easily port Python code to Scheme+
		     ;
		     ; the original Python code was:
		     ; z[i+1] = list(map(self.activation_function_hidden_layer,z̃[i+1]))
		     ; the Scheme+ port is:
		     {z[i + 1] <- vector-map(activation_function_hidden_layer z̃[i + 1])}

		     (display "z[i + 1] = ") (display {z[i + 1]}) (newline)

		  )

partial result:

> (send net accepte_et_propage #(1.7))
z̃[i + 1] = #(-1.606126902851834 -1.737502623605669)
z[i + 1] = #(-0.9225856290051391 -0.9399363289239167)
z̃[i + 1] = #(0.016731174898548362 1.7978079295067588 1.717414963798468)
z[i + 1] = #(0.01672961387506591 0.9465785338297136 0.9375510040999216)
>